[FFmpeg-user] drawtext automatic font size

lapinkulta12 at mail.ru lapinkulta12 at mail.ru
Wed Jun 5 23:27:07 EEST 2019


Hello, can someone please explain is it possible to make text fit in the picture with ffmpeg drawtext?
I have many various fonts and all have various size but i set "fontsize=48"

ffmpeg -i background.mp4 -vf "drawtext=text='Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua':x=240:y=570:fontfile=Caveat-Bold.ttf:fontsize=48:box=0:boxborderw=2:boxcolor=white at 0.1:fontcolor=white at 1:shadowcolor=black:shadowx=2:shadowy=3:enable=between'(t,0,5)'" -q:v 0 -threads 2 -video_track_timescale 30k -an -c:v libx264 -preset ultrafast -t 5 Caveat-Bold.mp4
and its make output like this:
https://www.infinitube.live/ffmpeg/Caveat-Bold.mp4
it draw many characters


but another font "TenorSans-Regular.ttf" draw much less letters in my video

ffmpeg -i background.mp4 -vf "drawtext=text='Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua':x=240:y=570:fontfile= TenorSans-Regular.ttf :fontsize=48:box=0:boxborderw=2:boxcolor=white at 0.1:fontcolor=white at 1:shadowcolor=black:shadowx=2:shadowy=3:enable=between'(t,0,5)'" -q:v 0 -threads 2 -video_track_timescale 30k -an -c:v libx264 -preset ultrafast -t 5  TenorSans .mp4

will results:
https://www.infinitube.live/ffmpeg/TenorSans.mp4


Maybe i can use some scale for font or i need calculate font width automaticaly before set it in " fontsize" option ? is it possible to make with ffmpeg?


More information about the ffmpeg-user mailing list