bash - 提取帧上的 ffmpeg 时间戳错误/提取帧的时间戳相等
问题描述
我有一组具有不同长度、大小、fps 等的视频,并从每个视频中准确提取 60 帧作为图像,并在每帧上加上时间戳。
为此,我将每个视频的长度除以 60,并用于fps=1/x
从视频中提取甚至几秒钟的帧。
这工作正常,但打印的时间戳略有偏差。
这是我使用的代码(bash 脚本的一部分)。
- 计算间隔:
output_frame_count=60
video_duration=$(ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 -i file.mp4)
capture_distance=$(bc <<< "scale=0; ($video_duration / $output_frame_count)")
- 然后使用参数运行 ffmpeg
ffmpeg -i file.mp4 -vf "fps=1/$capture_distance,scale=-1:$height,drawtext=fontfile=/usr/...: text='%{pts\:gmtime\:0\:%H\\\\\:%M\\\\\:%S}: x=(w-tw)/2: y=h-(2*lh): fontcolor=white: box=1: boxcolor=0x00000000@1" frames%04d.png
我检查了图像,与提取它们的原始图像相比,所有时间戳都是错误的。
有没有人有一种更可靠的方法来从一个印有正确时间戳的视频中准确提取 60 帧?
解决方案
推荐阅读
- excel - Using offset formula with CountIf for column
- html - div 定位(y 轴)与之前的 div y 轴位置相同,不需要的行为
- sql - 比较表 column_name 与视图 column_names
- python - Python to slack text Integration
- excel - 用于生成二维码的 VBA 代码,但代码从哪里开始?
- c++ - 类型别名的推导指南 ->
- webpack - 使用 wepack 在 sass 中添加“假”网址
- bash - 如何从文件中正确读取 BASH 参数?
- node.js - 我收到错误消息,使用 mocha 找不到模块 './--require.js'
- javascript - 通过维护逗号的内部值以逗号拆分数组