[Ffmpeg-devel] [PATCH]: A/V sync on nsv streams.

Michael Niedermayer michaelni
Fri Oct 27 12:04:32 CEST 2006


Hi

On Fri, Oct 27, 2006 at 03:18:54AM +0200, elupus wrote:
> The current nsv demuxer in ffmpeg doesn't handle discontinuous nsv streams
> very well. This is streams that might send a commercial before the actual
> program. When the stream switches the video is garbled and a/v desync
> occurs. 
> 
> A sample for this can be tried here http://69.9.180.91:8000;stream.nsv,
> (NOTE adult nature)
> 
> The nsv streaming format sends a parameter on each nsvf frame about the
> difference in timestamp between audio and video on that packet. So here is a
> patch that uses that information to set the dts value of the audio packet,
> fixes A/V sync on these types of streams.
> 
> Also, as noted by docs, the normal place a keyframe occurs is also on these
> sync frames, so I set the key flag only in those cases, should atleast be a
> little bit better. Currently, the video still breaks up on the change as the
> demuxer doesn't notify codec's on the content change, but i'm not sure how
> to solve that.

[...]

> @@ -637,7 +638,14 @@
>          }
>          av_get_packet(pb, pkt, asize);
>          pkt->stream_index = st[NSV_ST_AUDIO]->index;//NSV_ST_AUDIO;
> -        //pkt->dts = nst->frame_offset;
> +        if( nsv->state == NSV_HAS_READ_NSVS ) { /* on a nsvs frame we have new information on a/v sync */
> +            pkt->dts = av_rescale(((NSVStream*)st[NSV_ST_VIDEO]->priv_data)->frame_offset-1, 
> +                                  st[NSV_ST_AUDIO]->time_base.den * st[NSV_ST_VIDEO]->time_base.num,
> +                                  st[NSV_ST_AUDIO]->time_base.num * st[NSV_ST_VIDEO]->time_base.den);
> +            pkt->dts += av_rescale(nsv->avsync, 
> +                                   st[NSV_ST_AUDIO]->time_base.den * 1, 
> +                                   st[NSV_ST_AUDIO]->time_base.num * 1000);          

rescaling timestamps is unacceptable set the timebase correctly with
av_set_pts_info()

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

In the past you could go to a library and read, borrow or copy any book
Today you'd get arrested for mere telling someone where the library is




More information about the ffmpeg-devel mailing list