Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

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

ffmpeg failed to drawbox and set volume

I don't know what is wrong in my command with ffmpeg. Lets say I have a video and I want to make a black screen with muted audio between 20-30 seconds. So what I wrote is:

ffmpeg -i input.mp4 -filter_complex "[0:v]trim=0:20[0v];[0:a]atrim=0:20[0a];[0:v]trim=20:30,drawbox=color=black:t=fill[1v];[0:a]atrim=20:30,volume=0[1a];[0:v]trim=30:60[2v];[0:a]atrim=30:60[2a];[0v][1v][2v]concat=n=3:v=1:a=0[outv];[0a][1a][2a]concat=n=3:v=0:a=1[outa]" -map [outv] -map [outa] output.mp4

Now, I expect to have a video with 1 min length where the seconds between 20 & 30 are muted with black screen, but what I got is:

20 sec correct
20 sec freezing video with no audio
40 sec black video with no audio
30 sec correct

Can anyone help and tell me what is wrong in the command line?

question from:https://stackoverflow.com/questions/65914491/ffmpeg-failed-to-drawbox-and-set-volume

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

1 Reply

0 votes
by (71.8m points)

add setpts:

ffmpeg -i "input 2.mp4" -filter_complex "
[0:v] trim=0:20[0v];
[0:a]atrim=0:20[0a];
[0:v] trim=20:30, setpts=PTS-STARTPTS,drawbox=color=black:t=fill[1v];
[0:a]atrim=20:30,asetpts=PTS-STARTPTS,volume=0[1a];
[0:v] trim=30:60, setpts=PTS-STARTPTS[2v];
[0:a]atrim=30:60,asetpts=PTS-STARTPTS[2a];
[0v][0a][1v][1a][2v][2a]concat=n=3:v=1:a=1[outv][outa]
" -map [outv] -map [outa] output.mp4

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...