A script takes a single word 3 to 11 characters long, draws it with a custom font and overlays on top of a video. The word should fit a certain width.
The animation involves pan and zoom that the word follows. Maybe this compositing job suits smth like After Effects, but the task is ffmpeg implementation. I made it work with the shortest 3-character long sample word and the longest 11-character one.
drawtext
filter generates a transparent png with big margins around the text. zoompan
filter does the zooming afterwards.
I determined the font size for 3- and 11-char sample words and tried linear interpolation to get font size, depending on the word length. This approach fails with some words, as the font has variable width letters, and "MMM" vs. "III" differs n times in width.
Is there a way in ffmpeg to fit a variable-width text to fixed dimensions?
Maybe some filter to detect a least-sized rectangle with non-transparent pixels?
Plan-B works fine: bash function that calculates word length depending on each letter width in the particular font. Had to measure each letter width in Photoshop in pixels at 100pt font size.
Still wondering if there is a way ffmpeg could scale font size text to fit some fixed width.