/*
Copyright (C) 2013-2015 Carl Hetherington <cth@carlh.net>
- This program is free software; you can redistribute it and/or modify
+ This file is part of DCP-o-matic.
+
+ DCP-o-matic is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
- This program is distributed in the hope that it will be useful,
+ DCP-o-matic is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ffmpeg_audio_stream.h"
#include "ffmpeg_subtitle_stream.h"
#include "util.h"
-#include "safe_stringstream.h"
+#include <locked_sstream.h>
#include <boost/foreach.hpp>
#include <iostream>
s->codec->channel_layout = av_get_default_channel_layout (s->codec->channels);
}
+ DCPOMATIC_ASSERT (_format_context->duration != AV_NOPTS_VALUE);
+ DCPOMATIC_ASSERT (s->codec->codec);
+ DCPOMATIC_ASSERT (s->codec->codec->name);
+
_audio_streams.push_back (
shared_ptr<FFmpegAudioStream> (
- new FFmpegAudioStream (audio_stream_name (s), s->id, s->codec->sample_rate, s->codec->channels)
+ new FFmpegAudioStream (
+ stream_name (s),
+ s->codec->codec->name,
+ s->id,
+ s->codec->sample_rate,
+ (double (_format_context->duration) / AV_TIME_BASE) * s->codec->sample_rate,
+ s->codec->channels
+ )
)
);
if (job) {
if (_need_video_length) {
job->sub (_("Finding length and subtitles"));
- } else {
+ } else if (!_subtitle_streams.empty()) {
job->sub (_("Finding subtitles"));
+ } else {
+ job->sub (_("Finding length"));
}
}
return double (sar.num) / sar.den;
}
-string
-FFmpegExaminer::audio_stream_name (AVStream* s) const
-{
- SafeStringStream n;
-
- n << stream_name (s);
-
- if (!n.str().empty()) {
- n << "; ";
- }
-
- n << s->codec->channels << " channels";
-
- return n.str ();
-}
-
string
FFmpegExaminer::subtitle_stream_name (AVStream* s) const
{
- SafeStringStream n;
+ locked_stringstream n;
n << stream_name (s);
string
FFmpegExaminer::stream_name (AVStream* s) const
{
- SafeStringStream n;
+ locked_stringstream n;
if (s->metadata) {
AVDictionaryEntry const * lang = av_dict_get (s->metadata, "language", 0, 0);