[英]How to get frame number given a timestamp using ffmpeg
How can I get the frame number closest to a given time (relative to the start of the video) using ffmpeg?如何使用 ffmpeg 获得最接近给定时间(相对于视频的开始)的帧数? The video has variable frame rate .视频具有可变帧速率。 I do not need any other metadata or the actual frame (image) itself.我不需要任何其他元数据或实际帧(图像)本身。 Speed is more important than precision (unless the possible error is more than a couple of seconds).速度比精度更重要(除非可能的错误超过几秒钟)。
Example:例子:
Input输入
Output输出
ffmpeg -t 01:05 -i input.mp4 -nostats -vcodec copy -y -f rawvideo /dev/null 2>&1 | grep frame | awk '{print $2}' | tr -d ,
This ffmpeg command takes your input.mp4, truncates it to -t (in the example above 01:05, and writes the file to /dev/null. the -y
overwrites whatever is on /dev/null.这ffmpeg的命令需要你input.mp4,截断它-t(在上面的例子中01:05,并写入文件到/ dev / null的。在-y
覆写无论是在/ dev / null的。
The grep command grabs the number of frames. grep 命令获取帧数。
INPUT: ffmpeg -t 01:05 -i baywatch.mp4 -nostats -vcodec copy -y -f rawvideo /dev/null 2>&1 |输入:ffmpeg -t 01:05 -i baywatch.mp4 -nostats -vcodec copy -y -f rawvideo /dev/null 2>&1 | grep frame | grep框架| awk '{print $2}' | awk '{print $2}' | tr -d , tr -d ,
OUTPUT: 1559输出:1559
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.