FFmpeg覆盖帧号 [英] Frame Number Overlay With FFmpeg
本文介绍了FFmpeg覆盖帧号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要使用Windows的ffmpeg将帧号叠加到视频文件的每个帧上.
I need to overlay the frame number to each frame of a video file using ffmpeg for windows.
我成功使用以下代码将时间代码戳与drawtext
过滤器重叠:
I succeeded in overlaying a timecode stamp with the drawtext
filter using this code:
ffmpeg -i video.mov -vcodec r210 -vf "drawtext=fontfile=Arial.ttf: timecode='01\:00\:00\:00': r=25: x=(w-tw)/2: y=h-(2*lh): fontcolor=white: box=1: boxcolor=0x00000099" -y output.mov
但是,我需要一个帧号叠加层,而不是一个时间码.任何帮助将不胜感激.
However, I need a frame number overlay and not a timecode one. Any help would be appreciated.
推荐答案
您可以使用 drawtext过滤器和n
或frame_num
函数:
循环播放5 fps示例
示例命令:
ffmpeg -i input -vf "drawtext=fontfile=Arial.ttf: text='%{frame_num}': start_number=1: x=(w-tw)/2: y=h-(2*lh): fontcolor=black: fontsize=20: box=1: boxcolor=white: boxborderw=5" -c:a copy output
- 您可能必须提供字体文件的完整路径,例如
fontfile=/usr/share/fonts/TTF/Vera.ttf
. -
n
/frame_num
从0开始,但是您可以使用start_number
选项使帧数从1开始,如示例所示. - You may have to provide the full path to the font file, such as
fontfile=/usr/share/fonts/TTF/Vera.ttf
. n
/frame_num
starts at 0, but you can make the frame count start from 1 with thestart_number
option as shown in the example.
如果需要,您可以添加其他文本,但是请注意,您必须转义一些特殊字符:
You could add additional text if desired, but be aware that you have to escape some special characters:
text='Frame\: %{frame_num}'
有关更多信息,请参见 drawtext过滤器文档.
See the drawtext filter documentation for more info.
这篇关于FFmpeg覆盖帧号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文