帧数叠加与 FFmpeg [英] Frame Number Overlay With FFmpeg

查看:49
本文介绍了帧数叠加与 FFmpeg的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用 ffmpeg for windows 将帧号叠加到视频文件的每一帧上.

我使用以下代码成功地用 drawtext 过滤器覆盖了时间码戳:

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

但是,我需要一个帧号叠加而不是时间码叠加.任何帮助将不胜感激.

解决方案

您可以使用
循环 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:复制输出

  • 您可能需要提供字体文件的完整路径,例如 fontfile=/usr/share/fonts/TTF/Vera.ttf.
  • n/frame_num 从 0 开始,但您可以使用 start_number 选项使帧数从 1 开始,如示例所示.

如果需要,您可以添加其他文本,但请注意,您必须转义一些特殊字符:

text='Frame: %{frame_num}'

有关详细信息,请参阅 drawtext 过滤器文档.

I need to overlay the frame number to each frame of a video file using ffmpeg for windows.

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.

解决方案

You can use the drawtext filter with the n or frame_num function:


Looping 5 fps example

Example command:

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

  • 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 the start_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}'

See the drawtext filter documentation for more info.

这篇关于帧数叠加与 FFmpeg的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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