如何使用ffmpeg在视频的每个帧上显示帧号? [英] How to display a frame number on each frame of a video using ffmpeg?
问题描述
我的测试命令如下:
ffmpeg -i in.mov -vf "drawtext=fontfile=/usr/share/fonts/ttf-bitstream-vera/Vera.ttf: x=(w-tw)/2: y=h-(2*lh)-n: fontcolor=white: fontsize=40: box=1: boxcolor=0x00000000@1: text=" -an -y out.mov
我想显示每帧上的帧号。然而,将文本变量设置为n并没有帮助(它显示n),并且%n似乎是新的行符号。最令我困惑的是这部分
I want to display the frame number on each frame. However, setting the "text" variable to "n" does not help (it displays n) and %n seems to be the new line symbol. The thing that confuses me most is that this part
y=h-(2*lh)-n
效果很好,意味着它获取当前框架的正确值,并相应地移动文本。
works well, meaning it gets the right value of the current frame and moves the text up accordingly.
推荐答案
好的,这个功能不在 ffmpeg
中,但现在是。这是你如何做的:
Ok, this feature was not there in ffmpeg
, but now it is. And this is how you do it:
...drawtext=text=%{n}:expansion=normal:fontfile=/usr/share/fonts/ttf-bitstream-vera/Vera.ttf:other_options...
请注意,扩展应设置为正常,现在不是默认值,但应在将来默认(根据ffmpeg文档)。
Note that expansion should be set to normal, which is not the default now, but should be default in the future (according to the ffmpeg documentation).
这篇关于如何使用ffmpeg在视频的每个帧上显示帧号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!