ark1974
ark1974

Reputation: 655

ffmpeg - Overlay a text over a background image

The following command line for encoding audio with an image works fine.

ffmpeg -y -loop 1 -framerate 15 -i  "/storage/emulated/0/Download/Kites.jpg" -i "/storage/emulated/0/Download/myaudio.mp3"  -c:v libx264 -vf format=yuv420p -c:a aac -shortest "/storage/emulated/0/Download/Out.mp4"

I want to overlay text over an image in the video frame. Based on this link, I added an overlay text like so. Since I want to use the default font, I skip the drawtext="fontfile=" command deliberately like so. But now no video frames are visible, not even the background image. How can I do it? Thanks.

ffmpeg -y -loop 1 -framerate 15 -i  "/storage/emulated/0/Download/Kites.jpg" -i "/storage/emulated/0/Download/myaudio.mp3"  -c:v libx264 -vf format=yuv420p -vf drawtext="text='Hello World': fontcolor=white: fontsize=24: box=1: [email protected]: boxborderw=5: x=(w-text_w)/2: y=(h-text_h)/2"   -c:a aac -shortest "/storage/emulated/0/Download/Out.mp4"

Upvotes: 0

Views: 1430

Answers (1)

llogan
llogan

Reputation: 133833

Combine simple filters with a comma (,):

ffmpeg -y -loop 1 -framerate 15 -i "/storage/emulated/0/Download/Kites.jpg" -i "/storage/emulated/0/Download/myaudio.mp3" -c:v libx264 -vf "drawtext=text='Hello World': fontcolor=white: fontsize=24: box=1: [email protected]: boxborderw=5: x=(w-text_w)/2: y=(h-text_h)/2,format=yuv420p" -c:a aac -shortest "/storage/emulated/0/Download/Out.mp4"

See filtering introduction for more info.

Upvotes: 2

Related Questions