How can I set drawtext fontsize in ffmpeg according to resolutions ratio
drawtext, ffmpeg, scaling
Solution
Since ffmpeg version 3.4, video filter `drawtext` supports arithmetic expressions in its `fontsize` parameter. For example, height divided by 30:
-vf drawtext="fontsize=(h/30): x=(w-text_w)/2: y=(h-text_h*2): text='Hello, World!': fontcolor=white: box=1: boxcolor=black@0.5: boxborderw=5"
This will use font size 24 on a 720p video and 36 on a 1080p video.
See also more examples on how to use filter `drawtext` in ffmpeg documentation.
Problem
How can I set fontsize for drawtext on video according to width and height of each resolutions, to a certain proportion? ``` ffmpeg -i Input.mp4 -vf drawtext="fontfile=OpenSans-Regular.ttf: \ text='New Music Video': fontcolor=white: fontsize=?: r=25: box=1: boxcolor=black@0.3: \ boxborderw=3: x=(20)/2: y=(h-text_h-20) " Output.mp4 ``` I ask this question because when I set it to 24 `fontsize=24` for example,it size is defferent at other resolutions,when convert is done.