1 #include "ffmpeg_content.h"
2 #include "ffmpeg_decoder.h"
12 using boost::shared_ptr;
14 int const FFmpegContentProperty::SUBTITLE_STREAMS = 100;
15 int const FFmpegContentProperty::SUBTITLE_STREAM = 101;
16 int const FFmpegContentProperty::AUDIO_STREAMS = 102;
17 int const FFmpegContentProperty::AUDIO_STREAM = 103;
19 FFmpegContent::FFmpegContent (boost::filesystem::path f)
28 FFmpegContent::examine (shared_ptr<Film> film, shared_ptr<Job> job, bool quick)
31 Content::examine (film, job, quick);
34 job->set_progress_unknown ();
37 o.decode_audio = false;
38 shared_ptr<FFmpegDecoder> decoder (new FFmpegDecoder (film, shared_from_this (), o));
40 ContentVideoFrame video_length = 0;
42 video_length = decoder->video_length ();
43 film->log()->log (String::compose ("Video length obtained from header as %1 frames", decoder->video_length ()));
45 while (!decoder->pass ()) {
49 video_length = decoder->video_frame ();
50 film->log()->log (String::compose ("Video length examined as %1 frames", decoder->video_frame ()));
54 boost::mutex::scoped_lock lm (_mutex);
56 _video_length = video_length;
58 _subtitle_streams = decoder->subtitle_streams ();
59 if (!_subtitle_streams.empty ()) {
60 _subtitle_stream = _subtitle_streams.front ();
63 _audio_streams = decoder->audio_streams ();
64 if (!_audio_streams.empty ()) {
65 _audio_stream = _audio_streams.front ();
69 take_from_video_decoder (decoder);
71 Changed (VideoContentProperty::VIDEO_LENGTH);
72 Changed (FFmpegContentProperty::SUBTITLE_STREAMS);
73 Changed (FFmpegContentProperty::SUBTITLE_STREAM);
74 Changed (FFmpegContentProperty::AUDIO_STREAMS);
75 Changed (FFmpegContentProperty::AUDIO_STREAM);
79 FFmpegContent::summary () const
81 return String::compose (_("Movie: %1"), file().filename ());
85 FFmpegContent::set_subtitle_stream (FFmpegSubtitleStream s)
88 boost::mutex::scoped_lock lm (_mutex);
92 Changed (FFmpegContentProperty::SUBTITLE_STREAM);
96 FFmpegContent::set_audio_stream (FFmpegAudioStream s)
99 boost::mutex::scoped_lock lm (_mutex);
103 Changed (FFmpegContentProperty::AUDIO_STREAM);
107 FFmpegContent::audio_length () const
109 if (!_audio_stream) {
113 return video_frames_to_audio_frames (_video_length, audio_frame_rate(), video_frame_rate());
117 FFmpegContent::audio_channels () const
119 if (!_audio_stream) {
123 return _audio_stream->channels ();
127 FFmpegContent::audio_frame_rate () const
129 if (!_audio_stream) {
133 return _audio_stream->frame_rate;
137 FFmpegContent::audio_channel_layout () const
139 if (!_audio_stream) {
143 return _audio_stream->channel_layout;
147 operator== (FFmpegSubtitleStream const & a, FFmpegSubtitleStream const & b)
153 operator== (FFmpegAudioStream const & a, FFmpegAudioStream const & b)