black->make_black ();
for (int i = 0; i < black_video_frames; ++i) {
emit_video (black, shared_ptr<Subtitle> ());
+
+ /* This is a bit of a hack, but you can sort-of justify it if you squint at it right.
+ It's important because the encoder will probably use this to name its output frame.
+ */
+ ++_video_frames_in;
}
/* Now recompute our check value */
_delay_line->feed (audio);
+ int const in_frames = audio->frames ();
+
if (_opt->decode_range) {
/* Decode range in audio frames */
pair<int64_t, int64_t> required_range (
_audio_frames_in,
_audio_frames_in + audio->frames()
);
-
- if (required_range.first >= this_range.first && required_range.first < this_range.second) {
+
+ if (this_range.second < required_range.first || required_range.second < this_range.first) {
+ /* No part of this audio is within the required range */
+ audio->set_frames (0);
+ } else if (required_range.first >= this_range.first && required_range.first < this_range.second) {
/* Trim start */
- int64_t const shift = this_range.first - required_range.first;
+ int64_t const shift = required_range.first - this_range.first;
audio->move (shift, 0, audio->frames() - shift);
audio->set_frames (audio->frames() - shift);
} else if (required_range.second >= this_range.first && required_range.second < this_range.second) {
if (audio->frames()) {
emit_audio (audio);
}
+
+ _audio_frames_in += in_frames;
}
void
}
emit_video (*i, sub);
+ ++_video_frames_in;
}
-
- ++_video_frames_in;
}
void
}
emit_video (_last_image, _last_subtitle);
+ ++_video_frames_in;
}
void
TIMING ("encoder thread %1 wakes with queue of %2", boost::this_thread::get_id(), _queue.size());
boost::shared_ptr<DCPVideoFrame> vf = _queue.front ();
- _film->log()->log (String::compose ("Encoder thread %1 pops frame %2 from queue", boost::this_thread::get_id(), vf->frame()));
+ _film->log()->log (String::compose ("Encoder thread %1 pops frame %2 from queue", boost::this_thread::get_id(), vf->frame()), Log::VERBOSE);
_queue.pop_front ();
lock.unlock ();
/* Keep waking workers until the queue is empty */
while (!_queue.empty ()) {
- _film->log()->log ("Waking with " + lexical_cast<string> (_queue.size ()));
+ _film->log()->log ("Waking with " + lexical_cast<string> (_queue.size ()), Log::VERBOSE);
_worker_condition.notify_all ();
_worker_condition.wait (lock);
}
float const p = overall_progress ();
int const t = elapsed_time ();
int const r = remaining_time ();
-
+
stringstream s;
if (!finished () && p >= 0 && t > 10 && r > 0) {
s << rint (p * 100) << "%; " << seconds_to_approximate_hms (r) << " remaining";