diff options
| author | Carl Hetherington <cth@carlh.net> | 2016-05-10 13:50:47 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2016-05-18 11:50:29 +0100 |
| commit | 9423e02c37daba7f9e406929a1cfc1bb10fb4b62 (patch) | |
| tree | 96a4fc5435652a913a5732907474fc11968deb04 /src/lib | |
| parent | 90becb40eb48467b6d31d6939bcfcf39c3c9652c (diff) | |
Partial work on using a no-video FFmpeg file.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/ffmpeg.cc | 4 | ||||
| -rw-r--r-- | src/lib/ffmpeg_content.cc | 43 | ||||
| -rw-r--r-- | src/lib/ffmpeg_decoder.cc | 6 | ||||
| -rw-r--r-- | src/lib/ffmpeg_examiner.cc | 18 | ||||
| -rw-r--r-- | src/lib/ffmpeg_examiner.h | 2 |
5 files changed, 44 insertions, 29 deletions
diff --git a/src/lib/ffmpeg.cc b/src/lib/ffmpeg.cc index 7b1eae2b1..bfa3d4e7f 100644 --- a/src/lib/ffmpeg.cc +++ b/src/lib/ffmpeg.cc @@ -161,10 +161,6 @@ FFmpeg::setup_general () _video_stream = video_stream_undefined_frame_rate.get(); } - if (!_video_stream) { - throw DecodeError (N_("could not find video stream")); - } - /* Hack: if the AVStreams have duplicate IDs, replace them with our own. We use the IDs so that we can cope with VOBs, in which streams move about in index but remain with the same ID in different diff --git a/src/lib/ffmpeg_content.cc b/src/lib/ffmpeg_content.cc index a0bf88c25..bb9795f25 100644 --- a/src/lib/ffmpeg_content.cc +++ b/src/lib/ffmpeg_content.cc @@ -64,11 +64,7 @@ int const FFmpegContentProperty::FILTERS = 102; FFmpegContent::FFmpegContent (shared_ptr<const Film> film, boost::filesystem::path p) : Content (film, p) { - video.reset (new VideoContent (this, film)); - audio.reset (new AudioContent (this, film)); - subtitle.reset (new SubtitleContent (this, film)); - set_default_colour_conversion (); } FFmpegContent::FFmpegContent (shared_ptr<const Film> film, cxml::ConstNodePtr node, int version, list<string>& notes) @@ -210,35 +206,44 @@ FFmpegContent::examine (shared_ptr<Job> job) Content::examine (job); shared_ptr<FFmpegExaminer> examiner (new FFmpegExaminer (shared_from_this (), job)); - video->take_from_examiner (examiner); - set_default_colour_conversion (); + + if (examiner->has_video ()) { + video.reset (new VideoContent (this, film ())); + video->take_from_examiner (examiner); + set_default_colour_conversion (); + } { boost::mutex::scoped_lock lm (_mutex); - _subtitle_streams = examiner->subtitle_streams (); - if (!_subtitle_streams.empty ()) { - _subtitle_stream = _subtitle_streams.front (); + if (examiner->has_video ()) { + _first_video = examiner->first_video (); + _color_range = examiner->color_range (); + _color_primaries = examiner->color_primaries (); + _color_trc = examiner->color_trc (); + _colorspace = examiner->colorspace (); + _bits_per_pixel = examiner->bits_per_pixel (); } - BOOST_FOREACH (shared_ptr<FFmpegAudioStream> i, examiner->audio_streams ()) { - audio->add_stream (i); - } + if (!examiner->audio_streams().empty ()) { + audio.reset (new AudioContent (this, film ())); + + BOOST_FOREACH (shared_ptr<FFmpegAudioStream> i, examiner->audio_streams ()) { + audio->add_stream (i); + } - if (!audio->streams().empty ()) { AudioStreamPtr as = audio->streams().front(); AudioMapping m = as->mapping (); film()->make_audio_mapping_default (m); as->set_mapping (m); } - _first_video = examiner->first_video (); + _subtitle_streams = examiner->subtitle_streams (); + if (!_subtitle_streams.empty ()) { + subtitle.reset (new SubtitleContent (this, film ())); + _subtitle_stream = _subtitle_streams.front (); + } - _color_range = examiner->color_range (); - _color_primaries = examiner->color_primaries (); - _color_trc = examiner->color_trc (); - _colorspace = examiner->colorspace (); - _bits_per_pixel = examiner->bits_per_pixel (); } signal_changed (FFmpegContentProperty::SUBTITLE_STREAMS); diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc index 72df69126..d84bb2a52 100644 --- a/src/lib/ffmpeg_decoder.cc +++ b/src/lib/ffmpeg_decoder.cc @@ -77,8 +77,12 @@ FFmpegDecoder::FFmpegDecoder (shared_ptr<const FFmpegContent> c, shared_ptr<Log> , SubtitleDecoder (c->subtitle) , FFmpeg (c) , _log (log) - , _pts_offset (pts_offset (c->ffmpeg_audio_streams(), c->first_video(), c->active_video_frame_rate())) { + if (c->video) { + _pts_offset = pts_offset (c->ffmpeg_audio_streams(), c->first_video(), c->active_video_frame_rate()); + } else { + _pts_offset = ContentTime (); + } } void diff --git a/src/lib/ffmpeg_examiner.cc b/src/lib/ffmpeg_examiner.cc index eeb0cfc38..44d6a87df 100644 --- a/src/lib/ffmpeg_examiner.cc +++ b/src/lib/ffmpeg_examiner.cc @@ -72,10 +72,12 @@ FFmpegExaminer::FFmpegExaminer (shared_ptr<const FFmpegContent> c, shared_ptr<Jo } } - /* See if the header has duration information in it */ - _need_video_length = _format_context->duration == AV_NOPTS_VALUE; - if (!_need_video_length) { - _video_length = (double (_format_context->duration) / AV_TIME_BASE) * video_frame_rate().get (); + if (has_video ()) { + /* See if the header has duration information in it */ + _need_video_length = _format_context->duration == AV_NOPTS_VALUE; + if (!_need_video_length) { + _video_length = (double (_format_context->duration) / AV_TIME_BASE) * video_frame_rate().get (); + } } if (job) { @@ -169,7 +171,7 @@ FFmpegExaminer::FFmpegExaminer (shared_ptr<const FFmpegContent> c, shared_ptr<Jo this is because we might not know the PTS offset when the first subtitle is seen. Now we know the PTS offset so we can apply it to those subtitles. */ - if (video_frame_rate()) { + if (has_video() && video_frame_rate()) { BOOST_FOREACH (shared_ptr<FFmpegSubtitleStream> i, _subtitle_streams) { i->add_offset (pts_offset (_audio_streams, _first_video, video_frame_rate().get())); } @@ -477,3 +479,9 @@ FFmpegExaminer::yuv () const return false; } } + +bool +FFmpegExaminer::has_video () const +{ + return static_cast<bool> (_video_stream); +} diff --git a/src/lib/ffmpeg_examiner.h b/src/lib/ffmpeg_examiner.h index b9ca04e4c..258c2ea53 100644 --- a/src/lib/ffmpeg_examiner.h +++ b/src/lib/ffmpeg_examiner.h @@ -32,6 +32,8 @@ class FFmpegExaminer : public FFmpeg, public VideoExaminer public: FFmpegExaminer (boost::shared_ptr<const FFmpegContent>, boost::shared_ptr<Job> job = boost::shared_ptr<Job> ()); + bool has_video () const; + boost::optional<double> video_frame_rate () const; dcp::Size video_size () const; Frame video_length () const; |
