Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
375 views
in Technique[技术] by (71.8m points)

ffmpeg: How to keep audio synced when doing many (100) cuts with filter select='between(t,start,stop)+between...'

I am cutting out silent parts of a 45 minute video (a lecture). To do this, I use a filter to select, say one hundred, non-silent parts (I already know their start and end times).

ffmpeg -i in.mp4
-vf "select='between(t,start_1,stop_1)+...+between(t,start_100,stop_100)', setpts=N/FRAME_RATE/TB"
-af "aselect='between(t,start_1,stop_1)+...+between(t,start_100,stop_100)', asetpts=N/SR/TB"
-c:a aac -c:v libx264 out.mp4

It works, but at the end of the video the images are delayed relative to the audio. After reading this answer I also added

-shortest -avoid_negative_ts make_zero -fflags +genpts

at the end of the command. It didn't help.

As audio and video are concatenated independently I'm not surprised that tiny time errors due to finite frame rate add up.

Is there a solution that doesn't involve saving every non-silent part as a file?

question from:https://stackoverflow.com/questions/66052977/ffmpeg-how-to-keep-audio-synced-when-doing-many-100-cuts-with-filter-select

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...