Don't write empty <Text> nodes in subtitles/closed captions.
[dcpomatic.git] / test / ffmpeg_encoder_test.cc
index 74603f6c02699741da1b8ad4fcf593816aa9d774..d0bce03567065c24860fb9ab63faeb78baa460ff 100644 (file)
 */
 
 
+#include "lib/audio_content.h"
+#include "lib/compose.hpp"
+#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>
 
@@ -330,6 +331,18 @@ BOOST_AUTO_TEST_CASE (ffmpeg_encoder_h264_test6)
 }
 
 
+/** Test export of a 3D DCP in a 2D project */
+BOOST_AUTO_TEST_CASE (ffmpeg_encoder_3d_dcp_to_h264)
+{
+       auto dcp = make_shared<DCPContent>(TestPaths::private_data() / "xm");
+       auto film2 = new_test_film2 ("ffmpeg_encoder_3d_dcp_to_h264_export", {dcp});
+
+       auto job = make_shared<TranscodeJob> (film2);
+       FFmpegEncoder encoder (film2, job, "build/test/ffmpeg_encoder_3d_dcp_to_h264.mp4", ExportFormat::H264_AAC, true, false, false, 23);
+       encoder.go ();
+}
+
+
 /** Test export of a 3D DCP in a 2D project */
 BOOST_AUTO_TEST_CASE (ffmpeg_encoder_h264_test7)
 {
@@ -385,3 +398,60 @@ BOOST_AUTO_TEST_CASE (ffmpeg_encoder_h264_test9)
        FFmpegEncoder encoder (film, job, "build/test/ffmpeg_encoder_prores_test9.mov", ExportFormat::H264_AAC, false, false, false, 23);
        encoder.go ();
 }
+
+
+/** DCP -> Prores with crop */
+BOOST_AUTO_TEST_CASE (ffmpeg_encoder_prores_from_dcp_with_crop)
+{
+       auto dcp = make_shared<DCPContent>("test/data/import_dcp_test2");
+       auto film = new_test_film2 ("ffmpeg_encoder_prores_from_dcp_with_crop", { dcp });
+       dcp->video->set_left_crop (32);
+       dcp->video->set_right_crop (32);
+       film->write_metadata ();
+
+       auto job = make_shared<TranscodeJob>(film);
+       FFmpegEncoder encoder (film, job, "build/test/ffmpeg_encoder_prores_from_dcp_with_crop.mov", ExportFormat::PRORES, false, false, false, 23);
+       encoder.go ();
+}
+
+
+/** DCP -> H264 with crop */
+BOOST_AUTO_TEST_CASE (ffmpeg_encoder_h264_from_dcp_with_crop)
+{
+       auto dcp = make_shared<DCPContent>("test/data/import_dcp_test2");
+       auto film = new_test_film2 ("ffmpeg_encoder_h264_from_dcp_with_crop", { dcp });
+       dcp->video->set_left_crop (32);
+       dcp->video->set_right_crop (32);
+       film->write_metadata ();
+
+       auto job = make_shared<TranscodeJob>(film);
+       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");
+}
+