如何使用ffmpeg提取第一帧并恢复为图像? [英] How to extract the 1st frame and restore as an image with ffmpeg?

查看:40
本文介绍了如何使用ffmpeg提取第一帧并恢复为图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道诀窍吗?

以及如何安装 ffmpeg ?yum install mpeg 只返回这个:

======================================================================================== 匹配:mpeg =========================================================================================libiec61883.i386:IEEE1394 的流媒体库libiec61883.x86_64 :IEEE1394 的流媒体库qffmpeg-devel.i386:qffmpeg 的开发包qffmpeg-devel.x86_64 : qffmpeg 的开发包qffmpeg-libs.i386:qffmpeg 的库qffmpeg-libs.x86_64:qffmpeg 的库

解决方案

在手册页上:

<前>* 您可以从视频中提取图像,或从多个视频中创建视频图片:从视频中提取图像:ffmpeg -i foo.avi -r 1 -s WxH -f image2 foo-%03d.jpeg这将每秒从视频中提取一个视频帧,并将将它们输出到名为 foo-001.jpeg、foo-002.jpeg 等的文件中.将重新调整以适应新的 WxH 值.如果您只想提取有限数量的帧,您可以使用将上述命令与 -vframes 或 -t 选项结合使用,或在结合 -ss 从某个时间点开始提取.

当然你必须先安装它.我使用的是 Debian,不使用 yum.

[更新另一个问题]

<代码>我=1对于 *.avi 中的 avi;做ffmpeg -i $avi -vframes 1 -f image2/tmp/$i.jpg;i=$((i+1))完毕

经过测试并有效.

[更新另一个问题...]

<代码>对于 *.flv 中的 flv;做ffmpeg -i $flv -vframes 1 -f image2 ${flv%%.flv}.jpg完毕

Anyone knows the trick?

And how to install ffmpeg ? yum install mpeg only returns this:

======================================================================================== Matched: mpeg ========================================================================================
libiec61883.i386 : Streaming library for IEEE1394
libiec61883.x86_64 : Streaming library for IEEE1394
qffmpeg-devel.i386 : Development package for qffmpeg
qffmpeg-devel.x86_64 : Development package for qffmpeg
qffmpeg-libs.i386 : Libraries for qffmpeg
qffmpeg-libs.x86_64 : Libraries for qffmpeg

解决方案

It's on the manpage:

* You can extract images from a video, or create a video from many
       images:

       For extracting images from a video:

               ffmpeg -i foo.avi -r 1 -s WxH -f image2 foo-%03d.jpeg

       This will extract one video frame per second from the video and will
       output them in files named foo-001.jpeg, foo-002.jpeg, etc. Images
       will be rescaled to fit the new WxH values.

       If you want to extract just a limited number of frames, you can use
       the above command in combination with the -vframes or -t option, or in
       combination with -ss to start extracting from a certain point in time.

But of course you have to install it first. I'm on Debian and don't use yum.

[update for the other question]


i=1
for avi in *.avi; do
 ffmpeg -i $avi -vframes 1 -f image2 /tmp/$i.jpg; i=$((i+1))
done

Tested and works.

[update for yet another question...]


for flv in *.flv; do
 ffmpeg -i $flv -vframes 1 -f image2 ${flv%%.flv}.jpg
done

这篇关于如何使用ffmpeg提取第一帧并恢复为图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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