From 07ec83cd1f5249e81ea1ba41b0812a53471c5cc7 Mon Sep 17 00:00:00 2001 From: Alexander Reshetnikov Date: Wed, 28 Mar 2012 12:15:25 +0000 Subject: [PATCH] Updated ffmpeg test for big video writing (changed saving paths + added removing files) --- modules/highgui/test/test_ffmpeg.cpp | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/modules/highgui/test/test_ffmpeg.cpp b/modules/highgui/test/test_ffmpeg.cpp index 112ec72..680cf89 100644 --- a/modules/highgui/test/test_ffmpeg.cpp +++ b/modules/highgui/test/test_ffmpeg.cpp @@ -64,28 +64,45 @@ public: const size_t n = sizeof(codec_bmp_tags)/sizeof(codec_bmp_tags[0]); + bool created = false; + for (size_t j = 0; j < n; ++j) { stringstream s; s << codec_bmp_tags[j].tag; + const string filename = ts->get_data_path() + "../../../../output_"+s.str()+".avi"; + Mat img(img_r, img_c, CV_8UC3, Scalar::all(0)); try { - VideoWriter writer(string(ts->get_data_path()) + "video/output_"+s.str()+".avi", codec_bmp_tags[j].tag, fps, frame_s); + VideoWriter writer(filename, codec_bmp_tags[j].tag, fps, frame_s); + + if (writer.isOpened() == false) + { + ts->printf(ts->LOG, "\n\nFile name: %s\n", filename.c_str()); + ts->printf(ts->LOG, "Codec id: %d Codec tag: %d\n", j, codec_bmp_tags[j].tag); + ts->printf(ts->LOG, "Error: cannot create video file."); + ts->set_failed_test_info(ts->FAIL_INVALID_OUTPUT); + } - if (writer.isOpened() == false) ts->set_failed_test_info(cvtest::TS::FAIL_EXCEPTION); + else - for (int i = 0 ; i < static_cast(fps * time_sec); i++ ) { - //circle(img, Point2i(img_c / 2, img_r / 2), cv::min(img_r, img_c) / 2 * (i + 1), Scalar(255, 0, 0, 0), 2); - rectangle(img, Point2i(coeff * i, coeff * i), Point2i(coeff * (i + 1), coeff * (i + 1)), - Scalar::all(255 * (1.0 - static_cast(i) / (fps * time_sec * 2) )), -1); - writer << img; + for (int i = 0 ; i < static_cast(fps * time_sec); i++ ) + { + //circle(img, Point2i(img_c / 2, img_r / 2), cv::min(img_r, img_c) / 2 * (i + 1), Scalar(255, 0, 0, 0), 2); + rectangle(img, Point2i(coeff * i, coeff * i), Point2i(coeff * (i + 1), coeff * (i + 1)), + Scalar::all(255 * (1.0 - static_cast(i) / (fps * time_sec * 2) )), -1); + writer << img; + } + + if (!created) created = true; + else remove(filename.c_str()); } } catch(...) { - ts->set_failed_test_info(cvtest::TS::FAIL_EXCEPTION); + ts->set_failed_test_info(ts->FAIL_INVALID_OUTPUT); } ts->set_failed_test_info(cvtest::TS::OK); -- 2.7.4