[FFmpeg-user] How add expression in drawtext's text

DopeLabs dopelabs at dubstep.fm
Mon Jun 4 08:10:12 EEST 2018


this should give you a preview...

ffplay -f lavfi "color=c=black:s=640x480,drawtext=box=1:fontcolor=red:fontsize=20:text='%{eif\:n+1\:d\:5}':fontfile=OpenSans-Regular.ttf"

> On Jun 3, 2018, at 8:54 46PM, qw <applemax82 at 163.com> wrote:
> 
> 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
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
> 
> To unsubscribe, visit link above, or email
> ffmpeg-user-request at ffmpeg.org with subject "unsubscribe".



More information about the ffmpeg-user mailing list