From 9ce93abb29130d54daa441be92aad2d1562ef28b Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Thu, 23 Apr 2020 20:35:39 -0400 Subject: [PATCH] videotestsrc: Fix buffer duration in reverse playback 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: --- gst/videotestsrc/gstvideotestsrc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gst/videotestsrc/gstvideotestsrc.c b/gst/videotestsrc/gstvideotestsrc.c index d66035d0f7..4903581e55 100644 --- a/gst/videotestsrc/gstvideotestsrc.c +++ b/gst/videotestsrc/gstvideotestsrc.c @@ -1179,7 +1179,11 @@ gst_video_test_src_fill (GstPushSrc * psrc, GstBuffer * buffer) 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; }