gst-plugins-good: flvmux: Ensure Timestamp starts at 0

Mark Nauwelaerts mark.nauwelaerts at gmail.com
Wed Aug 27 13:41:47 PDT 2014


On 08/27/2014 07:20 PM, Nicolas Dufresne wrote:
> Module: gst-plugins-good
> Branch: master
> Commit: c1e7bec616d29a975a43e9fa69a5aa0250a044c4
> URL:    http://cgit.freedesktop.org/gstreamer/gst-plugins-good/commit/?id=c1e7bec616d29a975a43e9fa69a5aa0250a044c4
>
> Author: Nicolas Dufresne <nicolas.dufresne at collabora.co.uk>
> Date:   Mon Jul 28 20:58:59 2014 -0400
>
> flvmux: Ensure Timestamp starts at 0
>
> FLV documentation stipulates that timestamp must start at zero.
> In order to respect this rule, keep the first timestamp around
> and offset the timestamp from this value. This allow for longer
> recording time in presence of timestamp that does not start
> at 0 already.
>
> https://bugzilla.gnome.org/show_bug.cgi?id=731352
>
> ---
>
>   gst/flv/gstflvmux.c |    7 +++++++
>   gst/flv/gstflvmux.h |    1 +
>   2 files changed, 8 insertions(+)
>
> diff --git a/gst/flv/gstflvmux.c b/gst/flv/gstflvmux.c
> index b75adb4..ba08603 100644
> --- a/gst/flv/gstflvmux.c
> +++ b/gst/flv/gstflvmux.c
> @@ -529,6 +529,7 @@ gst_flv_mux_reset_pad (GstFlvMux * mux, GstFlvPad * cpad, gboolean video)
>       gst_buffer_unref (cpad->video_codec_data);
>     cpad->video_codec_data = NULL;
>     cpad->video_codec = G_MAXUINT;
> +  cpad->first_timestamp = GST_CLOCK_TIME_NONE;
>     cpad->last_timestamp = 0;
>   }
>   
> @@ -1020,6 +1021,12 @@ gst_flv_mux_buffer_to_tag_internal (GstFlvMux * mux, GstBuffer * buffer,
>     else
>       cts = 0;
>   
> +  if (!GST_CLOCK_TIME_IS_VALID (cpad->first_timestamp))
> +    cpad->first_timestamp = dts;
> +
> +  /* Timestamp must start at zero */
> +  dts -= cpad->first_timestamp;
> +
>     GST_LOG_OBJECT (mux, "got pts %i dts %i cts %i\n", pts, dts, cts);
>   
>     gst_buffer_map (buffer, &map, GST_MAP_READ);
> diff --git a/gst/flv/gstflvmux.h b/gst/flv/gstflvmux.h
> index cb57fc8..b7e0a1e 100644
> --- a/gst/flv/gstflvmux.h
> +++ b/gst/flv/gstflvmux.h
> @@ -53,6 +53,7 @@ typedef struct
>     GstBuffer *video_codec_data;
>   
>     GstClockTime last_timestamp;
> +  GstClockTime first_timestamp;
>   } GstFlvPad;
>   
>   typedef enum
>
> _______________________________________________
> gstreamer-commits mailing list
> gstreamer-commits at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-commits
This timestamp is being determined per-stream, and if a different offset is used 
per-stream, this could affect A/V sync afaics.

Mark.


More information about the gstreamer-devel mailing list