[FFmpeg-devel] [PATCH] flv muxer timestamp fix
Måns Rullgård
mans
Fri Jan 28 14:32:06 CET 2011
Benjamin Larsson <banan at ludd.ltu.se> writes:
> When streaming flv's with ffserver there is a timestamp jump in the
> beginning of the stream caused by the timestamp in the header to always
> start at 0. This patch fixes this by measuring between the current and
> previous timestamp and if it is to large it biases the timestamp so they
> are offset by a constant and thus removing the jump in timestamp.
>
> MvH
> Benjamin Larsson
>
> Index: libavformat/flvenc.c
> ===================================================================
> --- libavformat/flvenc.c (revision 26399)
> +++ libavformat/flvenc.c (working copy)
> @@ -56,6 +56,8 @@
> int64_t duration;
> int delay; ///< first dts delay for AVC
> int64_t last_video_ts;
> + int64_t ts_offset;
> + int64_t last_ts;
> } FLVContext;
>
> static int get_audio_flags(AVCodecContext *enc){
> @@ -361,6 +363,7 @@
> AVCodecContext *enc = s->streams[pkt->stream_index]->codec;
> FLVContext *flv = s->priv_data;
> unsigned ts;
> + int64_t last_ts;
> int size= pkt->size;
> uint8_t *data= NULL;
> int flags, flags_size;
> @@ -404,6 +407,11 @@
> flv->delay = -pkt->dts;
> }
>
> + last_ts = flv->last_ts;
> + flv->last_ts = ts;
> + if (ts - last_ts > 10000)
> + flv->ts_offset = ts - last_ts - 1;
> +
> ts = pkt->dts + flv->delay; // add delay to force positive dts
> if (enc->codec_type == AVMEDIA_TYPE_VIDEO) {
> if (flv->last_video_ts < ts)
I don't see you using the new struct fields for anything. Is the
patch incomplete?
--
M?ns Rullg?rd
mans at mansr.com
More information about the ffmpeg-devel
mailing list