Add a failing test.
[dcpomatic.git] / test / ffmpeg_encoder_test.cc
index c15973faed4ae9ef5b437da39fd825007bbdcd37..c3e8c9a81a8ccafa2713eac29325be836c8dbf41 100644 (file)
 */
 
 
+#include "lib/audio_content.h"
+#include "lib/compose.hpp"
+#include "lib/config.h"
+#include "lib/content_factory.h"
+#include "lib/dcp_content.h"
+#include "lib/ffmpeg_content.h"
 #include "lib/ffmpeg_encoder.h"
+#include "lib/ffmpeg_examiner.h"
 #include "lib/film.h"
-#include "lib/ffmpeg_content.h"
 #include "lib/image_content.h"
-#include "lib/video_content.h"
-#include "lib/audio_content.h"
-#include "lib/string_text_file_content.h"
 #include "lib/ratio.h"
-#include "lib/transcode_job.h"
-#include "lib/dcp_content.h"
+#include "lib/string_text_file_content.h"
 #include "lib/text_content.h"
-#include "lib/compose.hpp"
-#include "lib/content_factory.h"
+#include "lib/transcode_job.h"
+#include "lib/video_content.h"
 #include "test.h"
 #include <boost/test/unit_test.hpp>
 
@@ -39,7 +41,6 @@
 using std::string;
 using std::shared_ptr;
 using std::make_shared;
-using boost::optional;
 using namespace dcpomatic;
 
 
@@ -427,3 +428,59 @@ BOOST_AUTO_TEST_CASE (ffmpeg_encoder_h264_from_dcp_with_crop)
        FFmpegEncoder encoder (film, job, "build/test/ffmpeg_encoder_prores_from_dcp_with_crop.mov", ExportFormat::H264_AAC, false, false, false, 23);
        encoder.go ();
 }
+
+
+/** Export to H264 with reels */
+BOOST_AUTO_TEST_CASE (ffmpeg_encoder_h264_with_reels)
+{
+       auto content1 = content_factory("test/data/flat_red.png").front();
+       auto content2 = content_factory("test/data/flat_red.png").front();
+       auto film = new_test_film2 ("ffmpeg_encoder_h264_with_reels", { content1, content2 });
+       film->set_reel_type (ReelType::BY_VIDEO_CONTENT);
+       content1->video->set_length (240);
+       content2->video->set_length (240);
+
+       auto job = make_shared<TranscodeJob>(film);
+       FFmpegEncoder encoder (film, job, "build/test/ffmpeg_encoder_h264_with_reels.mov", ExportFormat::H264_AAC, false, true, false, 23);
+       encoder.go ();
+
+       auto check = [](boost::filesystem::path path) {
+               auto reel = std::dynamic_pointer_cast<FFmpegContent>(content_factory(path).front());
+               BOOST_REQUIRE (reel);
+               FFmpegExaminer examiner(reel);
+               BOOST_CHECK_EQUAL (examiner.video_length(), 240U);
+       };
+
+       check ("build/test/ffmpeg_encoder_h264_with_reels_reel1.mov");
+       check ("build/test/ffmpeg_encoder_h264_with_reels_reel2.mov");
+}
+
+
+/** Regression test for "Error during decoding: Butler finished" (#2097) */
+BOOST_AUTO_TEST_CASE (ffmpeg_encoder_prores_regression_1)
+{
+       auto content = content_factory(TestPaths::private_data() / "arrietty_JP-EN.mkv").front();
+       auto film = new_test_film2 ("ffmpeg_encoder_prores_regression_1", { content });
+
+       auto job = make_shared<TranscodeJob>(film);
+       FFmpegEncoder encoder (film, job, "build/test/ffmpeg_encoder_prores_regression_1.mov", ExportFormat::PRORES, false, true, false, 23);
+       encoder.go ();
+}
+
+
+/** Regression test for Butler video buffers reached 480 frames (audio is 0) (#2101) */
+BOOST_AUTO_TEST_CASE (ffmpeg_encoder_prores_regression_2)
+{
+       auto logs = Config::instance()->log_types();
+       Config::instance()->set_log_types(logs | LogEntry::TYPE_DEBUG_PLAYER);
+
+       auto content = content_factory(TestPaths::private_data() / "tge_clip.mkv").front();
+       auto film = new_test_film2 ("ffmpeg_encoder_prores_regression_2", { content });
+
+       auto job = make_shared<TranscodeJob>(film);
+       FFmpegEncoder encoder (film, job, "build/test/ffmpeg_encoder_prores_regression_2.mov", ExportFormat::PRORES, false, true, false, 23);
+       encoder.go ();
+
+       Config::instance()->set_log_types(logs);
+}
+