问:ffmpeg drawtext"localtime"是否为视频过滤器-以自定义格式显示 [英] Q: ffmpeg drawtext "localtime" video filter - display in custom format

查看:254
本文介绍了问:ffmpeg drawtext"localtime"是否为视频过滤器-以自定义格式显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到的问题是转义':'符号并以hms(HH:MM:SS)格式显示本地时间以覆盖在实时输入(MPEG-TS)上,然后将其作为实时输出推出-我已经我摸索无法显示"本地时间"的格式,该格式只能显示一半的内容我正在尝试实现,其代码示例为:

I'm having issues escaping ':' symbol and displaying localtime in a hms(HH:MM:SS) format for overlay over a Live input(MPEG-TS) which is then pushed out as Live output - I've fumbled my way to displaying 'localtime' in a format which achieves about half of what I'm trying to get to, the code sample of that is:

ffmpeg -re -hide_banner -i LIVE_INPUT -vf drawtext="fontsize=90:fontcolor=white:fontfile=/Windows/Fonts/arial.ttf:text='%{localtime\:%H %M %S}'" -f LIVE_OUTPUT

它实现的是以"HH MM SS"格式而不是"HH:MM:SS"显示本地时间...

What it achieves is that it displays local time in a "HH MM SS" format instead of "HH:MM:SS"...

我确实尝试通过这样写来转义:":

I did try escaping ':' by writing it like this:

ffmpeg -re -hide_banner -i LIVE_INPUT -vf drawtext="fontsize=90:fontcolor=white:fontfile=/Windows/Fonts/arial.ttf:text='%{localtime\:%H\\:%M\\:%S}'" -f LIVE_OUTPUT

和这个:

ffmpeg -re -hide_banner -i LIVE_INPUT -vf drawtext="fontsize=90:fontcolor=white:fontfile=/Windows/Fonts/arial.ttf:text='%{localtime\:%H\:%M\:%S}'" -f LIVE_OUTPUT

以及类似的内容:

ffmpeg -re -hide_banner -i LIVE_INPUT -vf drawtext="fontsize=90:fontcolor=white:fontfile=/Windows/Fonts/arial.ttf:text='%{localtime\:%H \: %M \: %S}'" -f LIVE_OUTPUT

但是上述方法均无济于事,因为它返回不同的错误,因为ffmpeg尝试将'%H''%M'和'%S'解析为本地时间的多个单独参数(本地时间然后抱怨说它只能接受x1参数最多),或者ffmpeg抱怨"H"附近有宽松的'%'字符...很明显,我没有正确地转义它,或者我的参数顺序不正确...

But none of the above helped as it returns different errors because ffmpeg tries to either parse '%H' '%M' and '%S' as multiple, separate arguments for localtime (localtime then complains that it can only accept x1 argument at most), or ffmpeg complains that there are loose '%' characters near "H" ... clearly I'm not escaping it correctly or my argument order is incorrect...

推荐答案

您最初显示HH:MM:SS的要求可以通过以下方式实现

Your original requirement of displaying HH:MM:SS can be achieved as follows

ffmpeg -re -hide_banner -i LIVE_INPUT \
-vf drawtext="fontsize=90:fontcolor=white: \
              fontfile=/Windows/Fonts/arial.ttf:text='%{localtime\:%X}'" \
-f LIVE_OUTPUT

这篇关于问:ffmpeg drawtext"localtime"是否为视频过滤器-以自定义格式显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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