diff options
| author | Carl Hetherington <cth@carlh.net> | 2022-03-28 00:23:16 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2022-03-28 00:23:16 +0200 |
| commit | 6a77d4a19541446008ab4c457d0fbeb256712d39 (patch) | |
| tree | e2be0151b93da06157046f6a92d28ff471320628 /src/lib/ffmpeg_content.cc | |
| parent | 72b0ae6df82b5e54e3f135f0c341f564a8bd7bc2 (diff) | |
WIP: hacks to allow joining of files which don't all have subtitle streams.2187-examine-vobs
Diffstat (limited to 'src/lib/ffmpeg_content.cc')
| -rw-r--r-- | src/lib/ffmpeg_content.cc | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/src/lib/ffmpeg_content.cc b/src/lib/ffmpeg_content.cc index 9017ad605..0d567f425 100644 --- a/src/lib/ffmpeg_content.cc +++ b/src/lib/ffmpeg_content.cc @@ -132,49 +132,53 @@ FFmpegContent::FFmpegContent (cxml::ConstNodePtr node, int version, list<string> } -FFmpegContent::FFmpegContent (vector<shared_ptr<Content>> c) - : Content (c) +FFmpegContent::FFmpegContent (vector<shared_ptr<Content>> content) + : Content (content) { - auto i = c.begin (); + auto i = content.begin (); bool need_video = false; bool need_audio = false; - bool need_text = false; + bool any_text = false; - if (i != c.end ()) { + if (i != content.end()) { need_video = static_cast<bool> ((*i)->video); need_audio = static_cast<bool> ((*i)->audio); - need_text = !(*i)->text.empty(); + any_text = !(*i)->text.empty(); } - while (i != c.end ()) { + while (i != content.end()) { if (need_video != static_cast<bool> ((*i)->video)) { throw JoinError (_("Content to be joined must all have or not have video")); } if (need_audio != static_cast<bool> ((*i)->audio)) { throw JoinError (_("Content to be joined must all have or not have audio")); } - if (need_text != !(*i)->text.empty()) { - throw JoinError (_("Content to be joined must all have or not have subtitles or captions")); + if (!(*i)->text.empty()) { + any_text = true; } ++i; } if (need_video) { - video = make_shared<VideoContent>(this, c); + video = make_shared<VideoContent>(this, content); } if (need_audio) { - audio = make_shared<AudioContent>(this, c); + audio = make_shared<AudioContent>(this, content); } - if (need_text) { - text.push_back (make_shared<TextContent>(this, c)); + if (any_text) { + text.push_back (make_shared<TextContent>(this, content)); } - auto ref = dynamic_pointer_cast<FFmpegContent> (c[0]); + /* Use the first content with a text as the reference */ + + auto ref_iter = std::find_if(content.begin(), content.end(), [](shared_ptr<Content> c) { return !c->text.empty(); }); + DCPOMATIC_ASSERT (ref_iter != content.end()); + auto ref = dynamic_pointer_cast<FFmpegContent>(*ref_iter); DCPOMATIC_ASSERT (ref); - for (size_t i = 0; i < c.size(); ++i) { - auto fc = dynamic_pointer_cast<FFmpegContent>(c[i]); + for (size_t i = 0; i < content.size(); ++i) { + auto fc = dynamic_pointer_cast<FFmpegContent>(content[i]); if (fc->only_text() && fc->only_text()->use() && *(fc->_subtitle_stream.get()) != *(ref->_subtitle_stream.get())) { throw JoinError (_("Content to be joined must use the same subtitle stream.")); } |
