Variable framerate/fps input video encoding questions

jles jlesquer at
Mon Jul 22 11:50:31 UTC 2019


I finally got it working with proper playing speeds, using the code down
below to calculate the buffer timestamps.
The mistake I did is that apart of this code I had the appsrc  go-timestamp
set to true (both at the same time).
Setting this to false and using the code below instead to calculate
timestamp, plays at normal speed and the resulting file gets proper file
duration and timestamps:

>> 		clock = gst_element_get_clock (GST_ELEMENT_CAST (appsrc));
>> 		if (clock) {
>> 		 base_time =
>> 		 gst_element_get_base_time (GST_ELEMENT_CAST (appsrc));
>> 		 now = gst_clock_get_time (clock);
>> 		 if (now > base_time)
>> 			 now -= base_time;
>> 		 else
>> 			 now = 0;
>> 		 gst_object_unref (clock);
>> 		 GST_BUFFER_PTS (buffer) = now;
>> 		 GST_BUFFER_DTS (buffer) = now;
>> 		}

Nicolas Dufresne-5 wrote
> Any jitter in your application will cause jitter in your timestamp with
> this method. Though, I don't see any specific errors right now. This is
> similar to the what the do-timestamp property on appsrc would do. This
> follow the formulat:
>   (now - base_time)
> Which is the running time, which match what appsrc will have by
> default. Ideally the timestamp would come from your camera and would be
> translated from one clock to another. This is what we try and do with
> v4l2src as an example (but it still a bit jittery I was told).

Yes, it is similar to do-timestamp would do but not quite, I test it with
only do-timestamp set to true to calculate time stamps, and it gets wrong
video frame duration, resulting in a fast played video (in my case). For
some reason the do-timestamp property doesn't work properly for recording
live streams...

Sent from:

More information about the gstreamer-devel mailing list