加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

如何使用php从图像创建视频?

发布时间:2020-12-13 16:42:24 所属栏目:PHP教程 来源:网络整理
导读:假设我有10张图像,我想将这些图像组合在像幻灯片的视频中. 例如,我想显示每个图像5秒,然后继续下一个图像另外5秒. 如果有可能,包括音乐和一些描述性的文字也是完美的. 有没有一个示例代码,这可能是用ffmpeg库? 我的第一个想法是用ffmpeg命令来解决这个问题.
假设我有10张图像,我想将这些图像组合在像幻灯片的视频中.

例如,我想显示每个图像5秒,然后继续下一个图像另外5秒.

如果有可能,包括音乐和一些描述性的文字也是完美的.

有没有一个示例代码,这可能是用ffmpeg库?

我的第一个想法是用ffmpeg命令来解决这个问题.

Creating a Video from Images

ffmpeg can be used to stitch several images together into a video.
There are many options,but the following example should be enough to
get started. It takes all images that have filenames of
XXXXX.morph.jpg,where X is numerical,and creates a video called
“output.mp4”. The qscale option specifies the picture quality (1 is
the highest,and 32 is the lowest),and the “-r” option is used to
specify the number of frames per second.

ffmpeg -r 25 -qscale 2 -i %05d.morph.jpg output.mp4

(The website that this blurb was taken from is gone. Link
has been removed.)

其中25表示每秒25张图像.您可以将其设置为1(略)(1秒)延迟或使用小数,IE:0.5延迟2秒.

然后,您可以将视频和音频流与此类似.

ffmpeg -i video.mp4 -i audio.mp3 -c:v copy -c:a aac -b:a 128k final.mp4

当然可以选择适合的编解码器.如果你想要一个mp4使用libx264的视频和aac(内置到ffmpeg,不再是“实验”)的音频.

只要记住,如果您选择使用ffmpeg输出的方法,默认情况下,当您尝试读取它时,stderr.如果你愿意,它可以被重定向到stdout.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读