tjk
tjk

Reputation: 161

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. E.g.:

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?

Upvotes: 2

Views: 2723

Answers (1)

Dirk V
Dirk V

Reputation: 1469

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

Upvotes: 1

Related Questions