1 #include "ffmpeg_content.h"
2 #include "ffmpeg_decoder.h"
11 using boost::shared_ptr;
13 int const FFmpegContentProperty::SUBTITLE_STREAMS = 100;
14 int const FFmpegContentProperty::SUBTITLE_STREAM = 101;
15 int const FFmpegContentProperty::AUDIO_STREAMS = 102;
16 int const FFmpegContentProperty::AUDIO_STREAM = 103;
18 FFmpegContent::FFmpegContent (boost::filesystem::path f)
27 FFmpegContent::examine (shared_ptr<Film> film, shared_ptr<Job> job, bool quick)
30 Content::examine (film, job, quick);
33 job->set_progress_unknown ();
35 shared_ptr<FFmpegDecoder> decoder (new FFmpegDecoder (film, shared_from_this (), true, false, false, true));
37 ContentVideoFrame video_length = 0;
39 video_length = decoder->video_length ();
40 film->log()->log (String::compose ("Video length obtained from header as %1 frames", decoder->video_length ()));
42 while (!decoder->pass ()) {
46 video_length = decoder->video_frame ();
47 film->log()->log (String::compose ("Video length examined as %1 frames", decoder->video_frame ()));
51 boost::mutex::scoped_lock lm (_mutex);
53 _video_length = video_length;
55 _subtitle_streams = decoder->subtitle_streams ();
56 if (!_subtitle_streams.empty ()) {
57 _subtitle_stream = _subtitle_streams.front ();
60 _audio_streams = decoder->audio_streams ();
61 if (!_audio_streams.empty ()) {
62 _audio_stream = _audio_streams.front ();
66 take_from_video_decoder (decoder);
68 Changed (VideoContentProperty::VIDEO_LENGTH);
69 Changed (FFmpegContentProperty::SUBTITLE_STREAMS);
70 Changed (FFmpegContentProperty::SUBTITLE_STREAM);
71 Changed (FFmpegContentProperty::AUDIO_STREAMS);
72 Changed (FFmpegContentProperty::AUDIO_STREAM);
76 FFmpegContent::summary () const
78 return String::compose (_("Movie: %1"), file().filename ());
82 FFmpegContent::set_subtitle_stream (FFmpegSubtitleStream s)
85 boost::mutex::scoped_lock lm (_mutex);
89 Changed (FFmpegContentProperty::SUBTITLE_STREAM);
93 FFmpegContent::set_audio_stream (FFmpegAudioStream s)
96 boost::mutex::scoped_lock lm (_mutex);
100 Changed (FFmpegContentProperty::AUDIO_STREAM);
104 FFmpegContent::audio_length () const
106 if (!_audio_stream) {
110 return video_frames_to_audio_frames (_video_length, audio_frame_rate(), video_frame_rate());
114 FFmpegContent::audio_channels () const
116 if (!_audio_stream) {
120 return _audio_stream->channels ();
124 FFmpegContent::audio_frame_rate () const
126 if (!_audio_stream) {
130 return _audio_stream->frame_rate;
134 FFmpegContent::audio_channel_layout () const
136 if (!_audio_stream) {
140 return _audio_stream->channel_layout;
144 operator== (FFmpegSubtitleStream const & a, FFmpegSubtitleStream const & b)
150 operator== (FFmpegAudioStream const & a, FFmpegAudioStream const & b)