X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Ftranscode_job.cc;h=46fc97fb31b74bdf14f6093dd0d973e34fa78709;hb=8aeb741ccbe2edb528e98a431bf55459a6836a9b;hp=0c3b8c37b978b9d5c94c058cfafbde11db552ec0;hpb=190c074cc1508c0aa429452ea920f8f94ef0d0f2;p=dcpomatic.git diff --git a/src/lib/transcode_job.cc b/src/lib/transcode_job.cc index 0c3b8c37b..46fc97fb3 100644 --- a/src/lib/transcode_job.cc +++ b/src/lib/transcode_job.cc @@ -25,10 +25,8 @@ #include #include "transcode_job.h" #include "film.h" -#include "format.h" #include "transcoder.h" #include "log.h" -#include "encoder.h" #include "i18n.h" @@ -40,7 +38,7 @@ using boost::shared_ptr; /** @param s Film to use. */ -TranscodeJob::TranscodeJob (shared_ptr f) +TranscodeJob::TranscodeJob (shared_ptr f) : Job (f) { @@ -58,7 +56,6 @@ TranscodeJob::run () try { _film->log()->log (N_("Transcode job starting")); - _film->log()->log (String::compose (N_("Audio delay is %1ms"), _film->audio_delay())); _transcoder.reset (new Transcoder (_film, shared_from_this ())); _transcoder->go (); @@ -66,13 +63,13 @@ TranscodeJob::run () set_state (FINISHED_OK); _film->log()->log (N_("Transcode job completed successfully")); + _transcoder.reset (); - } catch (std::exception& e) { - + } catch (...) { set_progress (1); set_state (FINISHED_ERROR); - _film->log()->log (String::compose (N_("Transcode job failed (%1)"), e.what())); - + _film->log()->log (N_("Transcode job failed or cancelled")); + _transcoder.reset (); throw; } } @@ -81,7 +78,7 @@ string TranscodeJob::status () const { if (!_transcoder) { - return _("0%"); + return Job::status (); } float const fps = _transcoder->current_encoding_rate (); @@ -93,8 +90,8 @@ TranscodeJob::status () const s << Job::status (); - if (!finished ()) { - s << N_("; ") << fixed << setprecision (1) << fps << N_(" ") << _("frames per second"); + if (!finished () && !_transcoder->finishing ()) { + s << "; " << fixed << setprecision (1) << fps << " " << _("frames per second"); } return s.str (); @@ -103,28 +100,20 @@ TranscodeJob::status () const int TranscodeJob::remaining_time () const { - if (!_transcoder) { + /* _transcoder might be destroyed by the job-runner thread */ + shared_ptr t = _transcoder; + + if (!t) { return 0; } - float fps = _transcoder->current_encoding_rate (); + float fps = t->current_encoding_rate (); if (fps == 0) { return 0; } - if (!_film->video_length()) { - return 0; - } - /* Compute approximate proposed length here, as it's only here that we need it */ - int length = _film->video_length(); - FrameRateConversion const frc (_film->video_frame_rate(), _film->dcp_frame_rate()); - if (frc.skip) { - length /= 2; - } - /* If we are repeating it shouldn't affect transcode time, so don't take it into account */ - - int const left = length - _transcoder->video_frames_out(); + VideoFrame const left = _film->time_to_video_frames (_film->length ()) - t->video_frames_out(); return left / fps; }