+ list<pair<shared_ptr<Image>, int64_t> > images = graph->process (_frame);
+
+ shared_ptr<const Film> film = _film.lock ();
+ assert (film);
+
+ for (list<pair<shared_ptr<Image>, int64_t> >::iterator i = images.begin(); i != images.end(); ++i) {
+
+ shared_ptr<Image> image = i->first;
+
+ if (i->second != AV_NOPTS_VALUE) {
+
+ double const pts = i->second * av_q2d (_format_context->streams[_video_stream]->time_base) + _pts_offset;
+
+ if (_just_sought) {
+ /* We just did a seek, so disable any attempts to correct for where we
+ are / should be.
+ */
+ _video_position = rint (pts * _ffmpeg_content->video_frame_rate ());
+ _just_sought = false;
+ }
+
+ double const next = _video_position / _ffmpeg_content->video_frame_rate();
+ double const one_frame = 1 / _ffmpeg_content->video_frame_rate ();
+ double delta = pts - next;
+
+ while (delta > one_frame) {
+ /* This PTS is more than one frame forward in time of where we think we should be; emit
+ a black frame.
+ */
+
+ /* XXX: I think this should be a copy of the last frame... */
+ boost::shared_ptr<Image> black (
+ new Image (
+ static_cast<AVPixelFormat> (_frame->format),
+ libdcp::Size (video_codec_context()->width, video_codec_context()->height),
+ true
+ )
+ );
+
+ shared_ptr<const Film> film = _film.lock ();
+ assert (film);
+
+ black->make_black ();
+ video (shared_ptr<ImageProxy> (new RawImageProxy (image, film->log())), false, _video_position);
+ delta -= one_frame;
+ }
+
+ if (delta > -one_frame) {
+ /* This PTS is within a frame of being right; emit this (otherwise it will be dropped) */
+ video (shared_ptr<ImageProxy> (new RawImageProxy (image, film->log())), false, _video_position);
+ }
+
+ } else {
+ LOG_WARNING ("Dropping frame without PTS");