[Ffmpeg-devel] [PATCH]: A/V sync on nsv streams.
elupus
elupus
Fri Oct 27 13:18:47 CEST 2006
Michael Niedermayer <michaelni <at> gmx.at> writes:
>
> 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.
> >
> [...]
>
> > <at> <at> -637,7 +638,14 <at> <at>
> > }
> > 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()
>
Okey, but should I then set the timebase to be the same timebase as video,
or to be in millisecond. The A/V correction is given in how many ms ahead of
the video the audio is. While the video is set to a standard fps. The audio
currently has a timebase of 1/samplespersecond, wich somewhat makes sence
(even thou it can only be directly used for pcm data currently).
Since the demuxer provides no other means of knowing sync between audio and
video I suppose it could make sence to use a timebase wich would give this
completly correct, if video has timebase a/b, then use 1/(1000b) for audio,
and set dts to frame*1000*a + sync*b. Would that be acceptable?
/Joakim
More information about the ffmpeg-devel
mailing list