FFMPEG -F Concat Video, Audio Sycn Issue

2019-03-03 08:35发布

i am having issue, to concat video, it looses the audio sync and audio started from previous video.

i have tried below two link/so answer by Mulvya, but none of them work :(

here is the code i am trying:

1: re-encode file a (1):

ffmpeg.exe -i "f:\1.avi" -af apad -vf scale=1280:720 -crf 15.0 -vcodec libx264 -acodec aac -ar 48000 -b:a 192k -coder 1 -rc_lookahead 60 -threads 0 -shortest -avoid_negative_ts make_zero -fflags +genpts 01.mp4

2: re-encode file b (2):

ffmpeg.exe -i "f:\2.mp4" -af apad -vf scale=1280:720 -crf 15.0 -vcodec libx264 -acodec aac -ar 48000 -b:a 192k -coder 1 -rc_lookahead 60 -threads 0 -shortest -avoid_negative_ts make_zero -fflags +genpts 02.mp4

3: Now contact using following command:

ffmpeg.exe -f concat -safe 0 -i "f:\files.txt" -c copy test.mp4

but audio is not synced with video ;(

i also uploaded both video (and also the output) on dropbox:

Video Sync Issue Source And Result Files

so, any help, how to make audio perfectly sync with video would be great :)

2条回答
Animai°情兽
2楼-- · 2019-03-03 08:59

Some one else on another forum helped me to find the issue. So, i post it as answer here so that someone else may can get help.

I was concerned about same frame size, audio and video codec to concat properly, but i forgot about frame rate.

That first sample video (mentioned in my question) frame rate was 12, while 2nd video frame rate was 25; and that's what make the sync problem.

Now, i have set frame rate 25 to those two video (-r 25) and it's works like charms :)

below is the full conversion code:

ffmpeg.exe -i "f:\1.avi" -r 25 -af apad -vf scale=1280:720 -crf 15.0 -vcodec libx264 -acodec aac -ar 48000 -b:a 192k -coder 1 -rc_lookahead 60 -threads 0 -shortest -avoid_negative_ts make_zero -fflags +genpts 01.mp4

hope it may help some one like me in near future.

best regards

查看更多
Rolldiameter
3楼-- · 2019-03-03 09:04

some other solution for syncing audio & video

use -bsf:v h264_mp4toannexb in your input files

ffmpeg.exe -i "1.avi" -af apad -vf scale=1280:720 -crf 15.0 -vcodec libx264 -acodec aac -bsf:v h264_mp4toannexb -ar 48000 -b:a 192k -coder 1 -rc_lookahead 60 -threads 0 -shortest -avoid_negative_ts make_zero -fflags +genpts output1.flv

and same for 2nd file

ffmpeg.exe -i "2.avi" -af apad -vf scale=1280:720 -crf 15.0 -vcodec libx264 -acodec aac -bsf:v h264_mp4toannexb -ar 48000 -b:a 192k -coder 1 -rc_lookahead 60 -threads 0 -shortest -avoid_negative_ts make_zero -fflags +genpts output2.flv

then files can be joined together

ffmpeg -f concat -safe 0 -i concat.txt -c copy -bsf:a aac_adtstoasc final.flv

where concat.txt file contains

file 'output1.flv'
file 'output2.flv'
查看更多
登录 后发表回答