#include "film.h"
#include "format.h"
#include "transcoder.h"
-#include "film_state.h"
#include "log.h"
#include "encoder_factory.h"
-using namespace std;
-using namespace boost;
+using std::string;
+using std::stringstream;
+using std::fixed;
+using std::setprecision;
+using boost::shared_ptr;
-/** @param s FilmState to use.
+/** @param s Film to use.
* @param o Options.
- * @param l A log that we can write to.
+ * @param req Job that must be completed before this job is run.
*/
-TranscodeJob::TranscodeJob (shared_ptr<const FilmState> s, shared_ptr<const Options> o, Log* l)
- : Job (s, o, l)
+TranscodeJob::TranscodeJob (shared_ptr<Film> f, shared_ptr<const Options> o, shared_ptr<Job> req)
+ : Job (f, req)
+ , _opt (o)
{
}
string
TranscodeJob::name () const
{
- stringstream s;
- s << "Transcode " << _fs->name;
- return s.str ();
+ return String::compose ("Transcode %1", _film->name());
}
void
{
try {
- _log->log ("Transcode job starting");
+ _film->log()->log ("Transcode job starting");
+ _film->log()->log (String::compose ("Audio delay is %1ms", _film->audio_delay()));
- _encoder = encoder_factory (_fs, _opt, _log);
- Transcoder w (_fs, _opt, this, _log, _encoder);
+ _encoder = encoder_factory (_film, _opt);
+ Transcoder w (_film, _opt, this, _encoder);
w.go ();
set_progress (1);
set_state (FINISHED_OK);
- _log->log ("Transcode job completed successfully");
+ _film->log()->log ("Transcode job completed successfully");
} catch (std::exception& e) {
- stringstream s;
set_progress (1);
set_state (FINISHED_ERROR);
-
- s << "Transcode job failed (" << e.what() << ")";
- _log->log (s.str ());
+ _film->log()->log (String::compose ("Transcode job failed (%1)", e.what()));
throw;
}
}
if (_encoder->skipping () && !finished ()) {
- return "skipping frames already encoded";
+ return "skipping already-encoded frames";
}
stringstream s;
- s << Job::status () << "; " << fixed << setprecision (1) << fps << " frames per second";
+ s << Job::status ();
+
+ if (!finished ()) {
+ s << "; " << fixed << setprecision (1) << fps << " frames per second";
+ }
+
return s.str ();
}
return 0;
}
- return ((_fs->length - _encoder->last_frame()) / fps);
+ /* We assume that dcp_length() is valid */
+ SourceFrame const left = _film->dcp_trim_start() + _film->dcp_length().get() - _encoder->video_frame();
+ return left / fps;
}