[FFmpeg-user] Synchronizing A/V streams from independent sources?

Francois Visagie francois.visagie at gmail.com
Mon Jun 2 08:29:01 CEST 2014


On 2 June 2014 08:20, Francois Visagie <francois.visagie at gmail.com> wrote:
>
> > -----Original Message-----
> > From: ffmpeg-user-bounces at ffmpeg.org [mailto:ffmpeg-user-
> > bounces at ffmpeg.org] On Behalf Of Jeff
> > Sent: 01 June 2014 17:11
> > To: ffmpeg-user at ffmpeg.org
> > Subject: [FFmpeg-user] Synchronizing A/V streams from independent
> > sources?
> >
> > I have two MP4 (H.264 AVC/AAC) A/V files, each with the same content.
> > For quality and other reasons, I want to extract the video stream from one
> of
> > them and the audio from the other, and mux the extracted streams together
> > in another MP4 file, which will be the final product. That much is the
> easy
> > part! :D
> >
> > For some reason, the source file which has my preferred video stream runs
> > slightly faster (1:20:32) than the source of my audio stream
> (1:23:58.000431).
> > Obviously, these streams cannot be synchronized by shifting the start
> time.
> >
> > I have, so far, tried 'setpts=PTS*1.xxxxxxxx' to slow and extend the
> video,
> > but this method introduces jerkiness regardless of whether I choose
> '-vsync
> > vfr' or 'cfr'. I get better (smooth, natural sounding) results by speeding
> up the
> > audio with 'atempo=1.xxxxxx' or with
> > 'asetpts=PTS*0.9xxxxxxx,aresample=async=5000'.
>
> Have you tried the '-map' option? It enables you to specify which stream to
> sync to - you could first try the one and then the other and see if that
> helps.

Sorry, scrap this bad idea. I see fortunately you already got much
better advice.

> > The main problem with stretching the video or shrinking the audio is that
> > granularity limitations are preventing a perfect match in running times
> that
> > would synchronize the two streams from beginning to end. Is there
> > something I am missing, some other approach to take? Something better
> > than stretching the one, shrinking the other, and by trial and error
> hoping to
> > find the point where they match up and synchronize?
> >
> > Here are a few more details on my two source streams:
> >
> > Video: '25 fps, 25 tbr, 16k tbn, 50 tbc' Recoding this stream (necessary
> to use
> > 'setpts' and 'vsync') with 'ffmpeg -c:v libx264'
> > changes tbn to 12800.
> >
> > Audio: 44100 Hz sample rate, 44100 tbn
> >
> > Thanks for your help.
> >
> > Jeff
> > _______________________________________________
> > ffmpeg-user mailing list
> > ffmpeg-user at ffmpeg.org
> > http://ffmpeg.org/mailman/listinfo/ffmpeg-user
>


More information about the ffmpeg-user mailing list