简体   繁体   中英

How make video and audio duration the same with ffmpeg?

I am merging a few user-generated videos together with ffmpeg-concat and sometimes run into an audio sync issue. I figured that it fails when audio and video duration mismatch. Eg:

ffprobe -v error -select_streams v:0 -show_entries stream=duration -of default=noprint_wrappers=1:nokey=1 IMG_7679.mov
16.666016
ffprobe -v error -select_streams a:0 -show_entries stream=duration -of default=noprint_wrappers=1:nokey=1 IMG_7679.mov
16.670998

Question is — how do make audio and video duration equal prior to concat, without loosing the content?

Or maybe classic ffmpeg's concat solves this issue somehow and I should use it?

you can use the trim and or atrim filter to cut a part of the audio or video.

[v]trim=0:3.23,setpts=START-PTS[vout]
[a]atrim=0:3.23,asetpts=START-PTS[aout]

setpts and asetpts fixes the timestamps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM