[FFmpeg-user] How to use drawtext to overlay dynamic text

Frank Tetzel s1445051 at mail.zih.tu-dresden.de
Wed Jun 11 22:25:39 CEST 2014


> > I am trying to find a way to use filters to draw dynamic text in the
> > same location on my video.  I understand how to draw static text
> > for a certain duration, so my plan was to chain multiple of these
> > filters together to make a dynamic text overlay, but I didn't find
> > a way to do two or more drawtext filters. What is the best way to
> > do something like this?  Any help is greatly appreciated.
> > 
> > This is the command I have so far to make static text
> > 
> > ffmpeg -i input.h264 -vf
> > "drawtext=enable='between(t,0,60)':fontfile=/Windows/Fonts/Tahoma.ttf:fontcolor='White':
> > text='100'" -acodec copy output.h264
> 
> You can make a linear chain of multiple filters by separating them
> with a comma:
> 
>   -vf "drawtext,drawtext"
> 
> See <http://ffmpeg.org/ffmpeg-filters.html#Filtergraph-syntax-1>
> 
> An alternative and possibly easier method would be to make an ASS or
> SRT subtitle and use the ass or subtitles filters to make hardsubs:
> 
>   -vf "subtitles=subtitles.srt"
> 
> See:
> http://ffmpeg.org/ffmpeg-filters.html#subtitles
> http://ffmpeg.org/ffmpeg-filters.html#ass
> https://trac.ffmpeg.org/wiki/HowToBurnSubtitlesIntoVideo
> 
> Or mux the subtitles if you prefer softsubs:
> 
>  ffmpeg -i video.mkv -i subtitles.ass -codec copy output.mkv
> 
> aegisub is an easy to use tool to make such subtitles.

If you only have a small amount of changes you could also use sendcmd.
http://ffmpeg.org/ffmpeg-filters.html#sendcmd_002c-asendcmd

see examples. Here's another one:
-vf "sendcmd=f=send.cmd,drawtext=fontsize=20:fontcolor=white:x=100:y=100:text='Hello World'"

send.cmd file:
5.0  drawtext reinit 'text=foo';
10.0 drawtext reinit 'text=bar';
20.0 drawtext reinit 'text=';



More information about the ffmpeg-user mailing list