在视频流上绘制动态文本 [英] Drawing dynamic text on video stream

查看:75
本文介绍了在视频流上绘制动态文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试每5分钟动态更改实时视频流中的文本 这是我使用的参数:

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"

我在FFMPEG控制台窗口中尝试了"c",但我做不到,我总是遇到解析错误. 是否有使用此选项的示例?

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?

谢谢.

推荐答案

除了重新加载外,您还需要自动写入文件.首先将文本更新为临时文件,然后重命名.如果不是这样,则在某些时候,FFMpeg会读取空数据,并且在创建文件且尚未写入任何文本时会失败.

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.

  • 在接下来的5分钟内用文本创建livetext.txt.tmp.
  • 将livetext.txt.tmp重命名为livetext.txt.

每5分钟重复一次此过程.

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"

通过重新加载,Ffmpeg每帧读取一次文本,因此更新几乎是瞬时的.有关详细信息,请参见 Drawtext过滤器

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

这篇关于在视频流上绘制动态文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆