From: Carl Hetherington Date: Wed, 11 Aug 2021 23:29:24 +0000 (+0200) Subject: Don't write empty nodes in subtitles/closed captions. X-Git-Tag: v2.15.158~24 X-Git-Url: https://git.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=689bf63d32a8276477ab12e83bd47a5ff67d3eae Don't write empty nodes in subtitles/closed captions. --- diff --git a/cscript b/cscript index a1684858a..ee4830945 100644 --- a/cscript +++ b/cscript @@ -388,8 +388,8 @@ def dependencies(target, options): # Use distro-provided FFmpeg on Arch deps = [] - deps.append(('libdcp', '9bc5ced')) - deps.append(('libsub', '749c204')) + deps.append(('libdcp', 'b3cb9c0')) + deps.append(('libsub', '587e475')) deps.append(('leqm-nrt', '93ae9e6')) deps.append(('rtaudio', 'f619b76')) # We get our OpenSSL libraries from the environment, but we diff --git a/src/lib/reel_writer.cc b/src/lib/reel_writer.cc index 521ba55df..7b9ea09bf 100644 --- a/src/lib/reel_writer.cc +++ b/src/lib/reel_writer.cc @@ -641,7 +641,7 @@ ReelWriter::create_reel_text ( } else if (ensure_subtitles) { /* We had no subtitle asset, but we've been asked to make sure there is one */ subtitle = maybe_add_text ( - empty_text_asset(TextType::OPEN_SUBTITLE, optional()), + empty_text_asset(TextType::OPEN_SUBTITLE, optional(), true), duration, reel, refs, @@ -670,7 +670,7 @@ ReelWriter::create_reel_text ( /* Make empty tracks for anything we've been asked to ensure but that we haven't added */ for (auto i: ensure_closed_captions) { auto a = maybe_add_text ( - empty_text_asset(TextType::CLOSED_CAPTION, i), duration, reel, refs, fonts, _default_font, film(), _period, output_dcp, _text_only + empty_text_asset(TextType::CLOSED_CAPTION, i, true), duration, reel, refs, fonts, _default_font, film(), _period, output_dcp, _text_only ); DCPOMATIC_ASSERT (a); a->set_annotation_text (i.name); @@ -784,7 +784,7 @@ ReelWriter::write (shared_ptr audio) shared_ptr -ReelWriter::empty_text_asset (TextType type, optional track) const +ReelWriter::empty_text_asset (TextType type, optional track, bool with_dummy) const { shared_ptr asset; @@ -815,29 +815,31 @@ ReelWriter::empty_text_asset (TextType type, optional track) const if (film()->encrypted()) { s->set_key (film()->key()); } - s->add ( - std::make_shared( - optional(), - false, - false, - false, - dcp::Colour(), - 42, - 1.0, - dcp::Time(0, 0, 0, 0, 24), - dcp::Time(0, 0, 1, 0, 24), - 0.5, - dcp::HAlign::CENTER, - 0.5, - dcp::VAlign::CENTER, - dcp::Direction::LTR, - "", - dcp::Effect::NONE, - dcp::Colour(), - dcp::Time(), - dcp::Time() - ) - ); + if (with_dummy) { + s->add ( + std::make_shared( + optional(), + false, + false, + false, + dcp::Colour(), + 42, + 1.0, + dcp::Time(0, 0, 0, 0, 24), + dcp::Time(0, 0, 1, 0, 24), + 0.5, + dcp::HAlign::CENTER, + 0.5, + dcp::VAlign::CENTER, + dcp::Direction::LTR, + " ", + dcp::Effect::NONE, + dcp::Colour(), + dcp::Time(), + dcp::Time() + ) + ); + } asset = s; } @@ -863,7 +865,7 @@ ReelWriter::write (PlayerText subs, TextType type, optional track, } if (!asset) { - asset = empty_text_asset (type, track); + asset = empty_text_asset (type, track, false); } switch (type) { diff --git a/src/lib/reel_writer.h b/src/lib/reel_writer.h index 804a93c05..5de00f641 100644 --- a/src/lib/reel_writer.h +++ b/src/lib/reel_writer.h @@ -103,7 +103,7 @@ private: long frame_info_position (Frame frame, Eyes eyes) const; Frame check_existing_picture_asset (boost::filesystem::path asset); bool existing_picture_frame_ok (FILE* asset_file, std::shared_ptr info_file, Frame frame) const; - std::shared_ptr empty_text_asset (TextType type, boost::optional track) const; + std::shared_ptr empty_text_asset (TextType type, boost::optional track, bool with_dummy) const; std::shared_ptr create_reel_picture (std::shared_ptr reel, std::list const & refs) const; void create_reel_sound (std::shared_ptr reel, std::list const & refs) const; diff --git a/test/data b/test/data index 1ba6c3a1d..1f4ca8962 160000 --- a/test/data +++ b/test/data @@ -1 +1 @@ -Subproject commit 1ba6c3a1d4b3b507ef868aaacf9fa0383a7f22a9 +Subproject commit 1f4ca89620199751370421f59ecd2e5d03318387 diff --git a/test/empty_caption_test.cc b/test/empty_caption_test.cc new file mode 100644 index 000000000..83f5cce5e --- /dev/null +++ b/test/empty_caption_test.cc @@ -0,0 +1,42 @@ +/* + Copyright (C) 2021 Carl Hetherington + + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DCP-o-matic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DCP-o-matic. If not, see . + +*/ + + +#include "lib/content.h" +#include "lib/content_factory.h" +#include "lib/film.h" +#include "lib/text_content.h" +#include "test.h" +#include + + +BOOST_AUTO_TEST_CASE (check_for_no_empty_text_nodes_in_failure_case) +{ + auto content = content_factory("test/data/empty.srt").front(); + auto film = new_test_film2 ("check_for_no_empty_text_nodes_in_failure_case", {content}); + auto text = content->text.front(); + text->set_type (TextType::CLOSED_CAPTION); + text->set_dcp_track({"English", dcp::LanguageTag("en-GB")}); + + make_and_verify_dcp (film, { + dcp::VerificationNote::Code::MISSING_CPL_METADATA + }); +} + diff --git a/test/wscript b/test/wscript index 797e5eefa..a158ffca1 100644 --- a/test/wscript +++ b/test/wscript @@ -69,6 +69,7 @@ def build(bld): dcp_playback_test.cc dcp_subtitle_test.cc digest_test.cc + empty_caption_test.cc empty_test.cc encryption_test.cc ffmpeg_audio_only_test.cc