I'm trying to use the drawtext filter in ffmpeg to add text to a video, but depending on the frame size, the text can either be too large (parts of it not even in the video frame) or too small (barely readable). Is there a way I can make the text automatically resize itself to perfectly fit the frame?

Here I am using to just put text in the top middle right now:

ffmpeg -i input.jpg -vf "drawtext=font='Impact': text='Test Text': fontcolor=white: borderw=3: fontsize-75: x=(w-tw)/2:y=h/12-th/2" output.jpg

Thanks in advance for anyone who helps.


Use the subtitles filter. Font size will autoscale to fit image.

  1. Make subtitles.srt:

    00:00:00,000 --> 00:00:05,000
    Text Text
  2. Encode:

    ffmpeg -i input.jpg -vf "subtitles=subtitles.srt:force_style='Fontname=Impact,Fontsize=75,Alignment=6'" -frames:v 1 -q:v 3 output.jpg
| improve this answer | |
  • Thanks - also do you know if it's possible, using this method, to specify the text for the subtitles without a separate subtitle file? – pigeonburger Aug 30 at 22:33
  • @pigeonburger Not that I know of. – llogan Aug 31 at 0:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.