[FFmpeg-user] How add expression in drawtext's text
qw
applemax82 at 163.com
Mon Jun 4 06:54:46 EEST 2018
Hi,
I can use the following command to add frame number on video:
/usr/local/bin/ffmpeg -t 180 -i input.mp4 -acodec libfdk_aac -ac 2 -b:a 48k -vcodec libx264 -b:v 500k -g 25 \
-vf "fps=fps=25, scale=w=320:h=240, drawtext='box=1:fontcolor=red:fontsize=20:fontfile=OpenSans-Regular.ttf:text=%{frame_num}'" \
-f mp4 out.mp4
But the width of the text box will increase as frame number increases. I want to make the width of the text box unchanged. If the largest frame number is 99999, I want to make the width of the text is of 5 numbers. How to do it?
Another question:
I want to make the following logic for text:
if frame number < 10
text=0000%{frame_num}
else if frame number < 100
text=000%{frame_num}
else if frame number < 1000
text=00%{frame_num}
else if frame number < 10000
text=0%{frame_num}
else
text=%{frame_num}
How to do it? How can I add expression in text? Is there any command example?
Thanks
regards
andrew
More information about the ffmpeg-user
mailing list