FFMPEG:从可变长度的视频中提取 20 张图像 [英] FFMPEG: Extracting 20 images from a video of variable length

查看:24
本文介绍了FFMPEG:从可变长度的视频中提取 20 张图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为此我已经非常仔细地浏览了互联网,但我没有找到我需要的东西,只有它的变体,这并不是我想要使用的东西.

I've browsed the internet for this very intensively, but I didn't find what I needed, only variations of it which are not quite the thing I want to use.

我有几个不同长度的视频,我想从每个视频中从头到尾提取 20 张图像,以显示视频的最广泛印象.

I've got several videos in different lengths and I want to extract 20 images out of every video from start to the end, to show the broadest impression of the video.

所以一个视频长 16m 47s =>总共 1007 秒 =>我必须每 50 秒拍一张视频快照.

So one video is 16m 47s long => 1007s in total => I have to make one snapshot of the video every 50 seconds.

所以我想使用 ffmpeg 的 -r 开关,其值为 0.019860973 (eq 20/1007) 但 ffmpeg 告诉我帧率太小了...

So I figured using the -r switch of ffmpeg with the value of 0.019860973 (eq 20/1007) but ffmpeg tells me that the framerate is too small for it...

我想出的唯一方法是编写一个脚本,该脚本通过操纵 -ss 开关调用 ffmpeg 并使用 -vframes 1 但这对我来说很慢而且有点不对,因为 ffmpegs 计算图像本身...

The only way I figured out to do it would be to write a script which calls ffmpeg with a manipulated -ss switch and using -vframes 1 but this is quite slow and a little bit off for me since ffmpegs numerates the images itself...

推荐答案

我也试图找到这个问题的答案.我利用了 radri 的回答,但发现它有一个错误.

I was trying to find the answer to this question too. I made use of radri's answer but found that it has a mistake.

ffmpeg -i video.avi -r 0.5 -f image2 output_%05d.jpg

每 2 秒产生一帧,因为 -r 表示帧速率.在这种情况下,每秒 0.5 帧,或每 2 秒 1 帧.

produces a frame every 2 seconds because -r means frame rate. In this case, 0.5 frames a second, or 1 frame every 2 seconds.

同理,如果您的视频时长为 1007 秒,而您只需要 20 帧,那么每 50.53 秒就需要一帧.转换为帧速率,将是每秒 0.01979 帧.

With the same logic, if your video is 1007 seconds long and you need only 20 frames, you need a frame every 50.53 seconds. Translated to frame rate, would be 0.01979 frames a second.

所以你的代码应该是

ffmpeg -i video.avi -r 0.01979 -f image2 output_%05d.jpg

我希望对某人有所帮助,就像它帮助了我一样.

I hope that helps someone, like it helped me.

这篇关于FFMPEG:从可变长度的视频中提取 20 张图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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