1

The ffmpeg documentation on filters doesn't have anything on a clipping rectangle for drawtext. I'm hoping there might be a setting I can put before a video filter to set a clip rect, an undocumented feature or a clever workaround so that you can draw the text only within a certain bounding box on the output video.

I'm trying to overlay movie titles over a ticking clock video. These might be long and I don't want them to spill over onto part of the clock. I know how to overlay text already. I am currently working around this by using a shorter version of the title.

Is this something that requires filter graphs or intermediate video files or can it be done with a simple video filter?

Beefster
  • 723
  • 7
  • 19

1 Answers1

2

enter image description here

Method 1: subtitles filter

Assuming you want simple clipping, and not bounded word wrapping, you can use ASS subtitles. See Visual Typesetting - Aegisub.

Once you make your subtitles file the ffmpeg command is simple:

ffmpeg -i input -filter_complex "subtitles=subs.ass" output

If you want to avoid using Aegisub you can manually make simple SRT style subs and then use the force_style option to set the clipping co-ordinates. See the subtitles filter documentation.

Method 2: crop

Another method would be to use crop, drawtext, and overlay filters. You can adapt the example in Blur specific area (without a mask).

llogan
  • 121,796
  • 28
  • 232
  • 243
  • Subtitles don't exactly do everything I need (I also want to do marquee text) and require generating an intermediate file, so I guess I'm stuck with filter graphs (i.e. Method 2). Thanks for the quick response. – Beefster Jan 03 '18 at 22:42
  • Do you know if it's possible to have rounded edges using the subtitles filter? – Leander Mihm Oct 26 '22 at 01:49