Drawing dynamic text on video stream

2019-03-06 03:05发布

I'm trying to change text dynamically every 5 minutes on my live video stream This is the argument im using:

-vf "drawtext=fontsize=40:fontfile=FreeSerif.ttf:text='hello world':x=(w-text_w)/2:y=(h-text_h)/2"

I tried 'c' in the FFMPEG console windows but I can't get it right, I always get a parse error. Is there an example of how to use this options?

Thanks.

标签: ffmpeg
1条回答
冷血范
2楼-- · 2019-03-06 03:46

Exept a reload you also need to write the file atomically. Update the text to a temporarily file first and then rename it. If not, at some point FFMpeg will read null data and fails when the file is created and no text is written yet.

  • Create livetext.txt.tmp with the text for the next 5 minutes.
  • Rename livetext.txt.tmp to livetext.txt.

repeat this process every 5 minutes.

-vf "drawtext=fontsize=40:fontfile=FreeSerif.ttf:textfile=/path/livetext.txt:x=(w-text_w)/2:y=(h-text_h)/2:reload=1"

With reload Ffmpeg reads the text every frame, so updates are almost instantaneous. For details see Drawtext filter

查看更多
登录 后发表回答