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

Categories

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.3k views
Welcome To Ask or Share your Answers For Others

1 Answer

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...