Add Unzipper.
[dcpomatic.git] / test / burnt_subtitle_test.cc
index 104cbe95ce5e4d0fcfbdea44ec447deb67c25546..8d7dcd143f872357fec0f542aceb3a7289e9e9cb 100644 (file)
@@ -30,6 +30,7 @@
 #include "lib/dcp_content.h"
 #include "lib/dcp_content_type.h"
 #include "lib/film.h"
+#include "lib/ffmpeg_encoder.h"
 #include "lib/log_entry.h"
 #include "lib/ratio.h"
 #include "lib/text_content.h"
@@ -149,3 +150,59 @@ BOOST_AUTO_TEST_CASE (burnt_subtitle_test_onto_dcp)
        check_dcp("test/data/burnt_subtitle_test_onto_dcp2", film2);
 #endif
 }
+
+
+
+/** Check positioning of some burnt subtitles from XML files */
+BOOST_AUTO_TEST_CASE(burnt_subtitle_test_position)
+{
+       auto check = [](string alignment)
+       {
+               auto const name = String::compose("burnt_subtitle_test_position_%1", alignment);
+               auto subs = content_factory(String::compose("test/data/burn_%1.xml", alignment));
+               auto film = new_test_film2(name, subs);
+               subs[0]->text[0]->set_use(true);
+               subs[0]->text[0]->set_burn(true);
+               make_and_verify_dcp(
+                       film,
+                       {
+                               dcp::VerificationNote::Code::MISSING_SUBTITLE_LANGUAGE,
+                               dcp::VerificationNote::Code::INVALID_SUBTITLE_FIRST_TEXT_TIME,
+                               dcp::VerificationNote::Code::MISSING_CPL_METADATA
+                       });
+
+#ifdef DCPOMATIC_WINDOWS
+               check_dcp(String::compose("test/data/windows/%1", name), film);
+#else
+               check_dcp(String::compose("test/data/%1", name), film);
+#endif
+       };
+
+       /* Should have a baseline 216 pixels from the top (0.2 * 1080) */
+       check("top");
+       /* Should have a baseline 756 pixels from the top ((0.5 + 0.2) * 1080) */
+       check("center");
+       /* Should have a baseline 864 pixels from the top ((1 - 0.2) * 1080) */
+       check("bottom");
+}
+
+
+/* Bug #2743 */
+BOOST_AUTO_TEST_CASE(burn_empty_subtitle_test)
+{
+       Cleanup cl;
+
+       auto content = content_factory("test/data/empty_sub.xml")[0];
+       auto film = new_test_film2("burnt_empty_subtitle_test", { content });
+       content->text[0]->set_use(true);
+
+       auto job = make_shared<TranscodeJob>(film, TranscodeJob::ChangedBehaviour::IGNORE);
+       auto file = boost::filesystem::path("build") / "test" / "burnt_empty_subtitle_test.mov";
+       cl.add(file);
+       FFmpegEncoder encoder(film, job, file, ExportFormat::PRORES_4444, false, false, false, 23);
+       encoder.go();
+
+       cl.run();
+}
+
+