In reverse playback, buffers have to be displayed at buffer.stop running
time, meaning:
buffer.pts + buffer.duration = prev_buffer.pts
=>
buffer.duration = prev_buffer.pts - buffer.pts
We were setting buffer.duration = next_buffer.pts - buffer.pts which
is not correct.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/646>
next_time = gst_util_uint64_scale (src->n_frames,
src->info.fps_d * GST_SECOND, src->info.fps_n);
if (src->reverse) {
- GST_BUFFER_DURATION (buffer) = src->running_time - next_time;
+ /* We already decremented to next frame */
+ GstClockTime prev_pts = gst_util_uint64_scale (src->n_frames + 2,
+ src->info.fps_d * GST_SECOND, src->info.fps_n);
+
+ GST_BUFFER_DURATION (buffer) = prev_pts - GST_BUFFER_PTS (buffer);
} else {
GST_BUFFER_DURATION (buffer) = next_time - src->running_time;
}