How to add text to video with ffmpeg without vhook

2019-04-03 00:22发布

问题:

I think question is simple enough. How to add text with ffmpeg vhook is deprecated and i couldn't find any easier solution.

Using ubuntu and installed latest ffmpeg version.

回答1:

FFmpeg from Ubuntu 10.04 does not appear to support filters, so you will have to get a more recent version. You can follow a step-by-step guide to compile ffmpeg on Ubuntu, or you can simply download a Linux build of ffmpeg.

Note that if you follow the compile guide you will need to additionally install libfreetype6-dev as a dependency and then add --enable-libfreetype to your ffmpeg ./configure.

This example command will add the words "Stack Overflow" to the video with a white background and centered in the middle of the video:

ffmpeg -i input -filter:v "drawtext=fontsize=30:box=1:fontfile=/usr/share/fonts/TTF/Vera.ttf:text='Stack Overflow':x=(w-text_w)/2:y=(h-text_h-line_h)/2" output

See the drawtext documentation for more details on additional parameters.



标签: ffmpeg