[FFmpeg-user] Synchronizing A/V streams from independent sources?
darkmoon at verizon.net
Sun Jun 1 17:10:51 CEST 2014
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
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.
More information about the ffmpeg-user