X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=blobdiff_plain;f=test%2Fffmpeg_encoder_test.cc;h=684a67cf5983be5bd4314fb2efa84754a057bba0;hp=b286bbdb4ed387e23aeb58fb8a5b3ffe532950ea;hb=dd9be86db6cde0afa5da0d1d1ac43b42e05dca26;hpb=a5c629cb9b638b67a0e4c2d26fe9ab2e124bf0eb diff --git a/test/ffmpeg_encoder_test.cc b/test/ffmpeg_encoder_test.cc index b286bbdb4..684a67cf5 100644 --- a/test/ffmpeg_encoder_test.cc +++ b/test/ffmpeg_encoder_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2017-2018 Carl Hetherington + Copyright (C) 2017-2019 Carl Hetherington This file is part of DCP-o-matic. @@ -30,33 +30,39 @@ #include "lib/dcp_content.h" #include "lib/text_content.h" #include "lib/compose.hpp" +#include "lib/content_factory.h" #include "test.h" #include using std::string; -using boost::shared_ptr; +using std::shared_ptr; +using boost::optional; +using namespace dcpomatic; static void -ffmpeg_content_test (int number, boost::filesystem::path content, FFmpegEncoder::Format format) +ffmpeg_content_test (int number, boost::filesystem::path content, ExportFormat format) { string name = "ffmpeg_encoder_"; string extension; switch (format) { - case FFmpegEncoder::FORMAT_H264: + case EXPORT_FORMAT_H264_AAC: name += "h264"; extension = "mp4"; break; - case FFmpegEncoder::FORMAT_PRORES: + case EXPORT_FORMAT_PRORES: name += "prores"; extension = "mov"; break; + case EXPORT_FORMAT_H264_PCM: + case EXPORT_FORMAT_SUBTITLES_DCP: + BOOST_REQUIRE (false); } name = String::compose("%1_test%2", name, number); shared_ptr film = new_test_film (name); film->set_name (name); - shared_ptr c (new FFmpegContent (film, content)); + shared_ptr c (new FFmpegContent(content)); film->set_container (Ratio::from_id ("185")); film->set_audio_channels (6); @@ -65,32 +71,32 @@ ffmpeg_content_test (int number, boost::filesystem::path content, FFmpegEncoder: film->write_metadata (); shared_ptr job (new TranscodeJob (film)); - FFmpegEncoder encoder (film, job, String::compose("build/test/%1.%2", name, extension), format, false); + FFmpegEncoder encoder (film, job, String::compose("build/test/%1.%2", name, extension), format, false, false, false, 23); encoder.go (); } /** Red / green / blue MP4 -> Prores */ BOOST_AUTO_TEST_CASE (ffmpeg_encoder_prores_test1) { - ffmpeg_content_test (1, "test/data/test.mp4", FFmpegEncoder::FORMAT_PRORES); + ffmpeg_content_test (1, "test/data/test.mp4", EXPORT_FORMAT_PRORES); } /** Dolby Aurora trailer VOB -> Prores */ BOOST_AUTO_TEST_CASE (ffmpeg_encoder_prores_test2) { - ffmpeg_content_test (2, private_data / "dolby_aurora.vob", FFmpegEncoder::FORMAT_PRORES); + ffmpeg_content_test (2, TestPaths::private_data() / "dolby_aurora.vob", EXPORT_FORMAT_PRORES); } /** Sintel trailer -> Prores */ BOOST_AUTO_TEST_CASE (ffmpeg_encoder_prores_test3) { - ffmpeg_content_test (3, private_data / "Sintel_Trailer1.480p.DivX_Plus_HD.mkv", FFmpegEncoder::FORMAT_PRORES); + ffmpeg_content_test (3, TestPaths::private_data() / "Sintel_Trailer1.480p.DivX_Plus_HD.mkv", EXPORT_FORMAT_PRORES); } /** Big Buck Bunny trailer -> Prores */ BOOST_AUTO_TEST_CASE (ffmpeg_encoder_prores_test4) { - ffmpeg_content_test (4, private_data / "big_buck_bunny_trailer_480p.mov", FFmpegEncoder::FORMAT_PRORES); + ffmpeg_content_test (4, TestPaths::private_data() / "big_buck_bunny_trailer_480p.mov", EXPORT_FORMAT_PRORES); } /** Still image -> Prores */ @@ -98,7 +104,7 @@ BOOST_AUTO_TEST_CASE (ffmpeg_encoder_prores_test5) { shared_ptr film = new_test_film ("ffmpeg_encoder_prores_test5"); film->set_name ("ffmpeg_encoder_prores_test5"); - shared_ptr c (new ImageContent (film, private_data / "bbc405.png")); + shared_ptr c (new ImageContent(TestPaths::private_data() / "bbc405.png")); film->set_container (Ratio::from_id ("185")); film->set_audio_channels (6); @@ -109,7 +115,7 @@ BOOST_AUTO_TEST_CASE (ffmpeg_encoder_prores_test5) film->write_metadata (); shared_ptr job (new TranscodeJob (film)); - FFmpegEncoder encoder (film, job, "build/test/ffmpeg_encoder_prores_test5.mov", FFmpegEncoder::FORMAT_PRORES, false); + FFmpegEncoder encoder (film, job, "build/test/ffmpeg_encoder_prores_test5.mov", EXPORT_FORMAT_PRORES, false, false, false, 23); encoder.go (); } @@ -121,7 +127,7 @@ BOOST_AUTO_TEST_CASE (ffmpeg_encoder_prores_test6) film->set_container (Ratio::from_id ("185")); film->set_audio_channels (6); - shared_ptr s (new StringTextFileContent (film, "test/data/subrip2.srt")); + shared_ptr s (new StringTextFileContent("test/data/subrip2.srt")); film->examine_and_add_content (s); BOOST_REQUIRE (!wait_for_jobs ()); s->only_text()->set_colour (dcp::Colour (255, 255, 0)); @@ -130,7 +136,7 @@ BOOST_AUTO_TEST_CASE (ffmpeg_encoder_prores_test6) film->write_metadata(); shared_ptr job (new TranscodeJob (film)); - FFmpegEncoder encoder (film, job, "build/test/ffmpeg_encoder_prores_test6.mov", FFmpegEncoder::FORMAT_PRORES, false); + FFmpegEncoder encoder (film, job, "build/test/ffmpeg_encoder_prores_test6.mov", EXPORT_FORMAT_PRORES, false, false, false, 23); encoder.go (); } @@ -142,11 +148,11 @@ BOOST_AUTO_TEST_CASE (ffmpeg_encoder_prores_test7) film->set_container (Ratio::from_id ("185")); film->set_audio_channels (6); - shared_ptr c (new FFmpegContent (film, "test/data/test.mp4")); + shared_ptr c (new FFmpegContent("test/data/test.mp4")); film->examine_and_add_content (c); BOOST_REQUIRE (!wait_for_jobs ()); - shared_ptr s (new StringTextFileContent (film, "test/data/subrip.srt")); + shared_ptr s (new StringTextFileContent("test/data/subrip.srt")); film->examine_and_add_content (s); BOOST_REQUIRE (!wait_for_jobs ()); s->only_text()->set_colour (dcp::Colour (255, 255, 0)); @@ -154,14 +160,14 @@ BOOST_AUTO_TEST_CASE (ffmpeg_encoder_prores_test7) s->only_text()->set_effect_colour (dcp::Colour (0, 255, 255)); shared_ptr job (new TranscodeJob (film)); - FFmpegEncoder encoder (film, job, "build/test/ffmpeg_encoder_prores_test7.mov", FFmpegEncoder::FORMAT_PRORES, false); + FFmpegEncoder encoder (film, job, "build/test/ffmpeg_encoder_prores_test7.mov", EXPORT_FORMAT_PRORES, false, false, false, 23); encoder.go (); } /** Red / green / blue MP4 -> H264 */ BOOST_AUTO_TEST_CASE (ffmpeg_encoder_h264_test1) { - ffmpeg_content_test(1, "test/data/test.mp4", FFmpegEncoder::FORMAT_H264); + ffmpeg_content_test(1, "test/data/test.mp4", EXPORT_FORMAT_H264_AAC); } /** Just subtitles -> H264 */ @@ -172,7 +178,7 @@ BOOST_AUTO_TEST_CASE (ffmpeg_encoder_h264_test2) film->set_container (Ratio::from_id ("185")); film->set_audio_channels (6); - shared_ptr s (new StringTextFileContent (film, "test/data/subrip2.srt")); + shared_ptr s (new StringTextFileContent("test/data/subrip2.srt")); film->examine_and_add_content (s); BOOST_REQUIRE (!wait_for_jobs ()); s->only_text()->set_colour (dcp::Colour (255, 255, 0)); @@ -181,7 +187,7 @@ BOOST_AUTO_TEST_CASE (ffmpeg_encoder_h264_test2) film->write_metadata(); shared_ptr job (new TranscodeJob (film)); - FFmpegEncoder encoder (film, job, "build/test/ffmpeg_encoder_h264_test2.mp4", FFmpegEncoder::FORMAT_H264, false); + FFmpegEncoder encoder (film, job, "build/test/ffmpeg_encoder_h264_test2.mp4", EXPORT_FORMAT_H264_AAC, false, false, false, 23); encoder.go (); } @@ -193,11 +199,11 @@ BOOST_AUTO_TEST_CASE (ffmpeg_encoder_h264_test3) film->set_container (Ratio::from_id ("185")); film->set_audio_channels (6); - shared_ptr c (new FFmpegContent (film, "test/data/test.mp4")); + shared_ptr c (new FFmpegContent("test/data/test.mp4")); film->examine_and_add_content (c); BOOST_REQUIRE (!wait_for_jobs ()); - shared_ptr s (new StringTextFileContent (film, "test/data/subrip.srt")); + shared_ptr s (new StringTextFileContent("test/data/subrip.srt")); film->examine_and_add_content (s); BOOST_REQUIRE (!wait_for_jobs ()); s->only_text()->set_colour (dcp::Colour (255, 255, 0)); @@ -206,7 +212,7 @@ BOOST_AUTO_TEST_CASE (ffmpeg_encoder_h264_test3) film->write_metadata(); shared_ptr job (new TranscodeJob (film)); - FFmpegEncoder encoder (film, job, "build/test/ffmpeg_encoder_h264_test3.mp4", FFmpegEncoder::FORMAT_H264, false); + FFmpegEncoder encoder (film, job, "build/test/ffmpeg_encoder_h264_test3.mp4", EXPORT_FORMAT_H264_AAC, false, false, false, 23); encoder.go (); } @@ -214,13 +220,13 @@ BOOST_AUTO_TEST_CASE (ffmpeg_encoder_h264_test3) BOOST_AUTO_TEST_CASE (ffmpeg_encoder_h264_test4) { shared_ptr film = new_test_film2("ffmpeg_encoder_h264_test4"); - film->examine_and_add_content(shared_ptr(new DCPContent(film, "test/data/scope_dcp"))); + film->examine_and_add_content(shared_ptr(new DCPContent("test/data/scope_dcp"))); BOOST_REQUIRE(!wait_for_jobs()); film->set_container(Ratio::from_id("185")); shared_ptr job(new TranscodeJob(film)); - FFmpegEncoder encoder(film, job, "build/test/ffmpeg_encoder_h264_test4.mp4", FFmpegEncoder::FORMAT_H264, false); + FFmpegEncoder encoder(film, job, "build/test/ffmpeg_encoder_h264_test4.mp4", EXPORT_FORMAT_H264_AAC, false, false, false, 23); encoder.go(); } @@ -232,50 +238,138 @@ BOOST_AUTO_TEST_CASE (ffmpeg_encoder_h264_test5) film->set_container (Ratio::from_id ("185")); film->set_audio_channels (6); - shared_ptr L (new FFmpegContent (film, "test/data/L.wav")); + shared_ptr L (new FFmpegContent("test/data/L.wav")); film->examine_and_add_content (L); - shared_ptr R (new FFmpegContent (film, "test/data/R.wav")); + shared_ptr R (new FFmpegContent("test/data/R.wav")); film->examine_and_add_content (R); - shared_ptr C (new FFmpegContent (film, "test/data/C.wav")); + shared_ptr C (new FFmpegContent("test/data/C.wav")); film->examine_and_add_content (C); - shared_ptr Ls (new FFmpegContent (film, "test/data/Ls.wav")); + shared_ptr Ls (new FFmpegContent("test/data/Ls.wav")); film->examine_and_add_content (Ls); - shared_ptr Rs (new FFmpegContent (film, "test/data/Rs.wav")); + shared_ptr Rs (new FFmpegContent("test/data/Rs.wav")); film->examine_and_add_content (Rs); - shared_ptr Lfe (new FFmpegContent (film, "test/data/Lfe.wav")); + shared_ptr Lfe (new FFmpegContent("test/data/Lfe.wav")); film->examine_and_add_content (Lfe); BOOST_REQUIRE (!wait_for_jobs ()); AudioMapping map (1, MAX_DCP_AUDIO_CHANNELS); - L->set_position (DCPTime::from_seconds (0)); + L->set_position (film, DCPTime::from_seconds(0)); map.make_zero (); map.set (0, 0, 1); L->audio->set_mapping (map); - R->set_position (DCPTime::from_seconds (1)); + R->set_position (film, DCPTime::from_seconds(1)); map.make_zero (); map.set (0, 1, 1); R->audio->set_mapping (map); - C->set_position (DCPTime::from_seconds (2)); + C->set_position (film, DCPTime::from_seconds(2)); map.make_zero (); map.set (0, 2, 1); C->audio->set_mapping (map); - Lfe->set_position (DCPTime::from_seconds (3)); + Lfe->set_position (film, DCPTime::from_seconds(3)); map.make_zero (); map.set (0, 3, 1); Lfe->audio->set_mapping (map); - Ls->set_position (DCPTime::from_seconds (4)); + Ls->set_position (film, DCPTime::from_seconds(4)); map.make_zero (); map.set (0, 4, 1); Ls->audio->set_mapping (map); - Rs->set_position (DCPTime::from_seconds (5)); + Rs->set_position (film, DCPTime::from_seconds(5)); map.make_zero (); map.set (0, 5, 1); Rs->audio->set_mapping (map); shared_ptr job (new TranscodeJob (film)); - FFmpegEncoder encoder (film, job, "build/test/ffmpeg_encoder_h264_test5.mp4", FFmpegEncoder::FORMAT_H264, true); + FFmpegEncoder encoder (film, job, "build/test/ffmpeg_encoder_h264_test5.mp4", EXPORT_FORMAT_H264_AAC, true, false, false, 23); encoder.go (); check_ffmpeg ("build/test/ffmpeg_encoder_h264_test5.mp4", "test/data/ffmpeg_encoder_h264_test5.mp4", 1); } + +/** Test export of a VF */ +BOOST_AUTO_TEST_CASE (ffmpeg_encoder_h264_test6) +{ + shared_ptr film = new_test_film2 ("ffmpeg_encoder_h264_test6_ov"); + film->examine_and_add_content (shared_ptr(new ImageContent(TestPaths::private_data() / "bbc405.png"))); + BOOST_REQUIRE (!wait_for_jobs()); + film->make_dcp (); + BOOST_REQUIRE (!wait_for_jobs()); + + shared_ptr film2 = new_test_film2 ("ffmpeg_encoder_h264_test6_vf"); + shared_ptr ov (new DCPContent("build/test/ffmpeg_encoder_h264_test6_ov/" + film->dcp_name(false))); + film2->examine_and_add_content (ov); + BOOST_REQUIRE (!wait_for_jobs()); + ov->set_reference_video (true); + shared_ptr subs = content_factory("test/data/subrip.srt").front(); + film2->examine_and_add_content (subs); + BOOST_REQUIRE (!wait_for_jobs()); + BOOST_FOREACH (shared_ptr i, subs->text) { + i->set_use (true); + } + + shared_ptr job (new TranscodeJob (film2)); + FFmpegEncoder encoder (film2, job, "build/test/ffmpeg_encoder_h264_test6_vf.mp4", EXPORT_FORMAT_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) +{ + shared_ptr film = new_test_film2 ("ffmpeg_encoder_h264_test7_data"); + shared_ptr L (shared_ptr(new ImageContent(TestPaths::private_data() / "bbc405.png"))); + film->examine_and_add_content (L); + shared_ptr R (shared_ptr(new ImageContent(TestPaths::private_data() / "bbc405.png"))); + film->examine_and_add_content (R); + BOOST_REQUIRE (!wait_for_jobs()); + L->video->set_frame_type (VIDEO_FRAME_TYPE_3D_LEFT); + L->set_position (film, DCPTime()); + R->video->set_frame_type (VIDEO_FRAME_TYPE_3D_RIGHT); + R->set_position (film, DCPTime()); + film->set_three_d (true); + film->make_dcp (); + BOOST_REQUIRE (!wait_for_jobs()); + + shared_ptr film2 = new_test_film2 ("ffmpeg_encoder_h264_test7_export"); + shared_ptr dcp (new DCPContent(film->dir(film->dcp_name()))); + film2->examine_and_add_content (dcp); + BOOST_REQUIRE (!wait_for_jobs()); + + shared_ptr job (new TranscodeJob (film2)); + FFmpegEncoder encoder (film2, job, "build/test/ffmpeg_encoder_h264_test7.mp4", EXPORT_FORMAT_H264_AAC, true, false, false, 23); + encoder.go (); +} + + +/** Stereo project with mixdown-to-stereo set */ +BOOST_AUTO_TEST_CASE (ffmpeg_encoder_h264_test8) +{ + shared_ptr film = new_test_film2("ffmpeg_encoder_h264_test4"); + film->examine_and_add_content(shared_ptr(new DCPContent("test/data/scope_dcp"))); + BOOST_REQUIRE(!wait_for_jobs()); + film->set_audio_channels (2); + + shared_ptr job(new TranscodeJob(film)); + FFmpegEncoder encoder(film, job, "build/test/ffmpeg_encoder_h264_test8.mp4", EXPORT_FORMAT_H264_AAC, true, false, false, 23); + encoder.go(); +} + + +/** 7.1/HI/VI (i.e. 12-channel) project */ +BOOST_AUTO_TEST_CASE (ffmpeg_encoder_h264_test9) +{ + shared_ptr film = new_test_film ("ffmpeg_encoder_prores_test9"); + film->set_name ("ffmpeg_encoder_prores_test9"); + shared_ptr c (new ImageContent(TestPaths::private_data() / "bbc405.png")); + film->set_container (Ratio::from_id ("185")); + film->set_audio_channels (12); + + film->examine_and_add_content (c); + BOOST_REQUIRE (!wait_for_jobs ()); + + c->video->set_length (240); + + film->write_metadata (); + shared_ptr job (new TranscodeJob (film)); + FFmpegEncoder encoder (film, job, "build/test/ffmpeg_encoder_prores_test9.mov", EXPORT_FORMAT_H264_AAC, false, false, false, 23); + encoder.go (); +}