Biswajit Chopdar
Biswajit Chopdar

Reputation: 871

How to combine these 2 commands to a single command?

I've 2 ffmpeg commands that I want to combine.

This code adds 2 drawtext to the input video, one at the starting and one at the end.

ffmpeg -i input.mp4 -vf "[in]drawtext=text='Stack Overflow': fontcolor=white: borderw=2: fontfile=Arial Black: fontsize=w*0.04: x=(w-text_w)-(w*0.04): y=(h-text_h)-(w*0.04): enable='between(t,0,6)', drawtext=text='Stack Overflow': fontcolor=white: borderw=2: fontfile=Arial Black: fontsize=w*0.04: x=(w-text_w)/2: y=(h-text_h)/2: enable='between(t,7,10)'[out]" -codec:a copy output2.mp4

and this code adds a red background to the video. I need to apply the red background to the second drawtext from 7 to 10 second.

ffmpeg -i input.mp4 -f lavfi -i "color=red:s=1280x720:d=4" -filter_complex "overlay" output.mp4

How to combine these two commands into a single command?

Upvotes: 0

Views: 76

Answers (1)

Gyan
Gyan

Reputation: 93048

Use

ffmpeg -i input.mp4 -vf "drawtext=text='Stack Overflow': fontcolor=white: borderw=2: fontfile=Arial Black: fontsize=w*0.04: x=(w-text_w)-(w*0.04): y=(h-text_h)-(w*0.04): enable='between(t,0,6)', drawbox=c=red:t=fill:enable='between(t,7,10)',drawtext=text='Stack Overflow': fontcolor=white: borderw=2: fontfile=Arial Black: fontsize=w*0.04: x=(w-text_w)/2: y=(h-text_h)/2: enable='between(t,7,10)'" -c:a copy output2.mp4

I just use the drawbox filter to paint the video red for the given time range, then draw text afterwards

Upvotes: 1

Related Questions