Use dcp::compose rather than our own.
[dcpomatic.git] / test / ffmpeg_encoder_test.cc
index 730b68100bc0c7ed87628ba6955157a6f380c12c..62c55e6829570f2d899c40ff4e6cc0238a0e8d87 100644 (file)
 */
 
 
+#include "lib/audio_content.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 <dcp/compose.h>
 #include <boost/test/unit_test.hpp>
 
 
@@ -64,7 +65,7 @@ ffmpeg_content_test (int number, boost::filesystem::path content, ExportFormat f
                BOOST_REQUIRE (false);
        }
 
-       name = String::compose("%1_test%2", name, number);
+       name = dcp::compose("%1_test%2", name, number);
 
        auto c = make_shared<FFmpegContent>(content);
        shared_ptr<Film> film = new_test_film2 (name, {c}, &cl);
@@ -73,7 +74,7 @@ ffmpeg_content_test (int number, boost::filesystem::path content, ExportFormat f
 
        film->write_metadata ();
        auto job = make_shared<TranscodeJob>(film);
-       auto file = boost::filesystem::path("build") / "test" / String::compose("%1.%2", name, extension);
+       auto file = boost::filesystem::path("build") / "test" / dcp::compose("%1.%2", name, extension);
        cl.add (file);
        FFmpegEncoder encoder (film, job, file, format, false, false, false, 23);
        encoder.go ();
@@ -397,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");
+}
+