开发者

PHP - Is it possible to create a video (any format) from a list of images using PHP?

开发者 https://www.devze.com 2023-01-29 15:48 出处:网络
I want to create a simple video slideshow using a list of images I have automatically using PHP. Is there some sort of library that allows video creation on PHP (like a PHP-GD library but for videos)?

I want to create a simple video slideshow using a list of images I have automatically using PHP. Is there some sort of library that allows video creation on PHP (like a PHP-GD library but for videos)? If it doesn't exist on PHP, what sort of language would allow easy video creation from pictu开发者_运维知识库res?

Also, if there was a way to include sound in the video, that would be even better. Thanks!


This PHP Video toolkit may help.


You can call a ffmpeg command line by PHP.

https://www.ffmpeg.org/download.html

For example, below command create a slideshow video with blend effect from 5 images

ffmpeg -framerate 20 \
-loop 1 -t 0.5 -i 1.jpg \
-loop 1 -t 0.5 -i 2.jpg \
-loop 1 -t 0.5 -i 3.jpg \
-loop 1 -t 0.5 -i 4.jpg \
-c:v libx264 \
-filter_complex " \
[1:v][0:v]blend=all_expr='A*(if(gte(T,0.5),1,T/0.5))+B*(1-(if(gte(T,0.5),1,T/0.5)))'[b1v]; \
[2:v][1:v]blend=all_expr='A*(if(gte(T,0.5),1,T/0.5))+B*(1-(if(gte(T,0.5),1,T/0.5)))'[b2v]; \
[3:v][2:v]blend=all_expr='A*(if(gte(T,0.5),1,T/0.5))+B*(1-(if(gte(T,0.5),1,T/0.5)))'[b3v]; \
[0:v][b1v][1:v][b2v][2:v][b3v][3:v]concat=n=7:v=1:a=0,format=yuv420p[v]" -map "[v]" out.mp4

You can check below memo for other effect ffmpeg memo

0

精彩评论

暂无评论...
验证码 换一张
取 消