Better progress indication when finding subs (#711).
authorCarl Hetherington <cth@carlh.net>
Sun, 11 Oct 2015 17:37:14 +0000 (18:37 +0100)
committerCarl Hetherington <cth@carlh.net>
Sun, 11 Oct 2015 17:37:14 +0000 (18:37 +0100)
ChangeLog
src/lib/ffmpeg_examiner.cc

index 7777862ceac0008fe2ec991abb80538376b19313..9d957bf154d90c63c5301da592cc9a3aec3a52ad 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2015-10-11  Carl Hetherington  <cth@carlh.net>
 
+       * Provide progress indication when finding
+       subtitles (#711).
+
        * Updated ru_RU translation from Igor Voytovich.
 
        * Updated pl_PL translation from Marek Skrzelowski.
index 40fe0d28ec5cae2e6bc89d800dd9ef57bb195402..4fd1b6fe8a8495ed9d326036ef07d712fb8efb8a 100644 (file)
@@ -76,13 +76,14 @@ FFmpegExaminer::FFmpegExaminer (shared_ptr<const FFmpegContent> c, shared_ptr<Jo
        _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 ();
-       } else if (job) {
-               job->sub (_("Finding length"));
-               job->set_progress_unknown ();
        }
 
        if (job) {
-               job->sub (_("Finding subtitles"));
+               if (_need_video_length) {
+                       job->sub (_("Finding length and subtitles"));
+               } else {
+                       job->sub (_("Finding subtitles"));
+               }
        }
 
        /* Run through until we find:
@@ -95,6 +96,7 @@ FFmpegExaminer::FFmpegExaminer (shared_ptr<const FFmpegContent> c, shared_ptr<Jo
         * so they are ok).
         */
 
+       int64_t const len = _file_group.length ();
        while (true) {
                int r = av_read_frame (_format_context, &_packet);
                if (r < 0) {
@@ -102,7 +104,11 @@ FFmpegExaminer::FFmpegExaminer (shared_ptr<const FFmpegContent> c, shared_ptr<Jo
                }
 
                if (job) {
-                       job->set_progress_unknown ();
+                       if (len > 0) {
+                               job->set_progress (float (_format_context->pb->pos) / len);
+                       } else {
+                               job->set_progress_unknown ();
+                       }
                }
 
                AVCodecContext* context = _format_context->streams[_packet.stream_index]->codec;