X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fffmpeg_content.cc;h=a12f45a30f81d20d6af73fb97e0b62f805a54a54;hb=74fe68e5895654e27a7cf8097917c1e95fa89519;hp=a191959fcf6bceb42f94630823fcf1afb1dd45a7;hpb=85d343a420c4df1a08663c8afd3bdb73c8dfa985;p=dcpomatic.git diff --git a/src/lib/ffmpeg_content.cc b/src/lib/ffmpeg_content.cc index a191959fc..a12f45a30 100644 --- a/src/lib/ffmpeg_content.cc +++ b/src/lib/ffmpeg_content.cc @@ -33,9 +33,12 @@ extern "C" { #include "film.h" #include "log.h" #include "exceptions.h" +#include "frame_rate_change.h" #include "i18n.h" +#define LOG_GENERAL(...) film->log()->log (String::compose (__VA_ARGS__), Log::TYPE_GENERAL); + using std::string; using std::stringstream; using std::vector; @@ -107,7 +110,7 @@ FFmpegContent::FFmpegContent (shared_ptr f, vector fc = dynamic_pointer_cast (c[i]); - if (f->with_subtitles() && *(fc->_subtitle_stream.get()) != *(ref->_subtitle_stream.get())) { + if (fc->subtitle_use() && *(fc->_subtitle_stream.get()) != *(ref->_subtitle_stream.get())) { throw JoinError (_("Content to be joined must use the same subtitle stream.")); } @@ -173,7 +176,7 @@ FFmpegContent::examine (shared_ptr job) shared_ptr film = _film.lock (); assert (film); - film->log()->log (String::compose ("Video length obtained from header as %1 frames", video_length.frames (video_frame_rate ()))); + LOG_GENERAL ("Video length obtained from header as %1 frames", video_length.frames (video_frame_rate ())); { boost::mutex::scoped_lock lm (_mutex); @@ -392,3 +395,21 @@ FFmpegContent::audio_analysis_path () const p /= name; return p; } + +bool +FFmpegContent::has_subtitle_during (ContentTimePeriod period) const +{ + shared_ptr stream = subtitle_stream (); + if (!stream) { + return false; + } + + /* XXX: inefficient */ + for (vector::const_iterator i = stream->periods.begin(); i != stream->periods.end(); ++i) { + if (i->from <= period.to && i->to >= period.from) { + return true; + } + } + + return false; +}