Fix start-trim of audio-only content (#915).
[dcpomatic.git] / src / lib / transcode_job.cc
index b52d0238f3c10b1b91b9cfdc53f1a6db99b84d54..8e56603302e1200382197965d51b8c0cbf0f1ee1 100644 (file)
@@ -28,7 +28,7 @@
 #include "film.h"
 #include "transcoder.h"
 #include "log.h"
-#include "safe_stringstream.h"
+#include <locked_sstream.h>
 #include "compose.hpp"
 #include <iostream>
 #include <iomanip>
@@ -83,7 +83,7 @@ TranscodeJob::run ()
 
                float fps = 0;
                if (finish.tv_sec != start.tv_sec) {
-                       fps = _transcoder->video_frames_out() / (finish.tv_sec - start.tv_sec);
+                       fps = _transcoder->video_frames_enqueued() / (finish.tv_sec - start.tv_sec);
                }
 
                LOG_GENERAL (N_("Transcode job completed successfully: %1 fps"), fps);
@@ -112,13 +112,13 @@ TranscodeJob::status () const
                return Job::status ();
        }
 
-       SafeStringStream s;
+       locked_stringstream s;
 
        s << Job::status ();
 
        if (!finished () && !_transcoder->finishing ()) {
                /// TRANSLATORS: fps here is an abbreviation for frames per second
-               s << "; " << _transcoder->video_frames_out() << "/"
+               s << "; " << _transcoder->video_frames_enqueued() << "/"
                  << _film->length().frames_round (_film->video_frame_rate ()) << " " << _("frames") << "; "
                  << fixed << setprecision (1) << fps << " " << _("fps");
        }
@@ -133,10 +133,13 @@ TranscodeJob::remaining_time () const
        /* _transcoder might be destroyed by the job-runner thread */
        shared_ptr<Transcoder> t = _transcoder;
 
-       if (!t) {
-               return 0;
+       if (!t || t->finishing()) {
+               /* We aren't doing any actual encoding so just use the job's guess */
+               return Job::remaining_time ();
        }
 
+       /* We're encoding so guess based on the current encoding rate */
+
        float fps = t->current_encoding_rate ();
 
        if (fps == 0) {
@@ -144,5 +147,5 @@ TranscodeJob::remaining_time () const
        }
 
        /* Compute approximate proposed length here, as it's only here that we need it */
-       return (_film->length().frames_round (_film->video_frame_rate ()) - t->video_frames_out()) / fps;
+       return (_film->length().frames_round (_film->video_frame_rate ()) - t->video_frames_enqueued()) / fps;
 }