ffmpeg 图像到视频脚本有人吗? [英] ffmpeg images-to-video script anyone?

查看:29
本文介绍了ffmpeg 图像到视频脚本有人吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想拍摄一堆图像并从中制作视频幻灯片.会有一个应用程序,对吧?是的,似乎有不少.问题是我希望将幻灯片与一段音乐同步,而我见过的所有应用程序都只允许您将每张幻灯片显示一整秒的倍数.我希望它们显示 1.714285714 秒的倍数以适应 140 bpm.

I'm wanting to take a bunch of images and make a video slideshow out of them. There'll be an app for that, right? Yup, quite a few it seems. The problem is I want the slides synced to a piece of music, and all the apps I've seen only allow you to show each slide for a multiple of a whole second. I want them to show for multiples of 1.714285714 seconds to fit with 140 bpm.

我所见过的工具一般似乎都有 ffmpeg 在底层,所以想必这种事情可以用脚本来完成.但是 ffmpeg 有很多选择......我希望有人能有一些接近的东西.

The tools I've seen generally seem to have ffmpeg under the hood, so presumably this kind of thing could be done with a script. But ffmpeg has sooo many options...I'm hoping someone will have something close.

我最多可以有大约 100 张幻灯片,那些必须显示 3.428571428 秒或我想我可以简单地显示两次的幻灯片.

I'll have up to about 100 slides, the ones that have to show for 3.428571428 secs or whatever I guess I can simply show twice.

推荐答案

您可以从视频中提取图像,或从多个视频中创建视频图片:

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

这将每秒从视频中提取一个视频帧,并将将它们输出到名为foo-001.jpeg"、foo-002.jpeg"等的文件中.将重新调整以适应新的 WxH 值.如果你想提取只是有限数量的帧,你可以使用上面的命令与 -vframes 或 -t 选项组合,或与 -ss 组合从某个时间点开始提取.用于制作视频来自许多图像:

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. For creating a video from many images:

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

语法foo-%03d.jpeg指定使用十进制数组成用零填充的三位数字来表示序列号.它与 C printf 函数支持的语法相同,但仅接受普通整数的格式是合适的.

The syntax foo-%03d.jpeg specifies to use a decimal number composed of three digits padded with zeroes to express the sequence number. It is the same syntax supported by the C printf function, but only formats accepting a normal integer are suitable.

这是文档的摘录,有关详细信息,请查看 ffmpeg 的文档页面.

This is an excerpt from the documentation, for more info check on the documentation page of ffmpeg.

这篇关于ffmpeg 图像到视频脚本有人吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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