X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=blobdiff_plain;f=src%2Flib%2Fffmpeg_examiner.cc;h=544cc11b91fc545d2d74426b5ab372db4933fdd1;hp=44d6a87dfdd6b262b4eaafd5d54ab678d7c809d8;hb=422be0eece2bf6ee80db1d3c21553cd82efff789;hpb=9423e02c37daba7f9e406929a1cfc1bb10fb4b62 diff --git a/src/lib/ffmpeg_examiner.cc b/src/lib/ffmpeg_examiner.cc index 44d6a87df..544cc11b9 100644 --- a/src/lib/ffmpeg_examiner.cc +++ b/src/lib/ffmpeg_examiner.cc @@ -1,19 +1,20 @@ /* Copyright (C) 2013-2015 Carl Hetherington - 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 . */ @@ -29,7 +30,7 @@ extern "C" { #include "ffmpeg_audio_stream.h" #include "ffmpeg_subtitle_stream.h" #include "util.h" -#include "safe_stringstream.h" +#include #include #include @@ -61,9 +62,20 @@ FFmpegExaminer::FFmpegExaminer (shared_ptr c, shared_ptrcodec->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 ( - 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 + ) ) ); @@ -83,8 +95,10 @@ FFmpegExaminer::FFmpegExaminer (shared_ptr c, shared_ptrsub (_("Finding length and subtitles")); - } else { + } else if (!_subtitle_streams.empty()) { job->sub (_("Finding subtitles")); + } else { + job->sub (_("Finding length")); } } @@ -334,26 +348,10 @@ FFmpegExaminer::sample_aspect_ratio () const 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); @@ -367,7 +365,7 @@ FFmpegExaminer::subtitle_stream_name (AVStream* s) const 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);