I'm trying to add text to my video. Something like this:

So far I've tried this command, but the text doesn't wrap:

ffmpeg -i input.mp4 -vf \
"format=yuv444p, \
drawbox=y=ih/PHI:[email protected]:width=iw:height=48:t=fill, \
drawtext=fontfile=OpenSans-Regular.ttf:text='Title of this    Video':fontcolor=white:fontsize=24:x=(w-tw)/2:y=(h/PHI)+th, \
format=yuv420p" \
-c:v libx264 -c:a copy -movflags +faststart output.mp4

2 Answers 2


Use the subtitles filter and it will wrap automatically. You can use the simple but limited SRT format, or the more complex ASS format. Aegisub is useful if you want to format the subtitles, or see the force_style option in the subtitles filter.

enter image description here

ffmpeg -i input.mp4 -vf "subtitles=title.srt,format=yuv420p" -c:v libx264 -c:a copy -movflags +faststart output.mp4
  • I'd also like(the caption) to be in the bottom or on the top of the video as it is in the picture in the question
    – archie
    Commented Sep 17, 2019 at 18:35
  • @archie Yes, that is possible. Refer to Alignment or \an or \pos tags. docs.aegisub.org/3.2/ASS_Tags
    – llogan
    Commented Sep 17, 2019 at 18:37
  • How is the title.srt supposed to be like? I'm getting "Conversion failed" message
    – archie
    Commented Sep 18, 2019 at 17:37
  • @archie Example. But you should be using ASS since it supports the \an and \pos tags.
    – llogan
    Commented Sep 18, 2019 at 18:38

The drawtext filter doesn't support automatic wrapping.

So, if you want to display your text in n lines, you have to use the drawtext filter n times, with different values for parameters text, y (and maybe x, too) for every line.

  • Would it be responsive that way?
    – archie
    Commented Sep 18, 2019 at 17:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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