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

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

问题描述

我已经非常深入地浏览了互联网,但是我没有找到需要的内容,只有其中的变体不是我想要使用的。



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



所以一个视频是16m 47s long => 1007s总共=>我必须每50秒制作一次视频快照。



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



唯一的方法我想到这样做会写一个脚本,调用ffmpeg与一个被操纵的-ss开关,并使用-vframes 1,但这是相当缓慢和一点点,因为ffmpegs计算图像本身...


任何建议或指示?



谢谢,
Vapire

解决方案

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

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

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



与同样的逻辑,如果你的视频是1007秒长,你只需要20帧,每50.53秒需要一个帧。翻译成帧速率,每秒0.01979帧。



所以你的代码应该是

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

我希望帮助某人帮助我。


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.

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.

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

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...

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...

Any suggestions or directions?

Thanks, Vapire

解决方案

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

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.

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.

So your code should be

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天全站免登陆