Create Video File using PHP

Avinash picture Avinash · May 5, 2011 · Viewed 21.1k times · Source

I have scenario for creating a video files using diff. assets like images, audio file.

What I want to do is, Find audio files from the particular folder and set it as background music, and fetch images from particular folder and show those images one by one.

So basically I have images and audio files and I want create a video file using those assets using PHP.

Can any one please suggest the start up point for this? Have done image capture from video and converting the video using Ffmpeg so I have think of Ffmpeg but, I think it will not allow to create a video.

Answer

Phil Lello picture Phil Lello · May 5, 2011

ffmpeg will allow you to create videos from still images.

For example, to create a video with a 10fps frame rate, from images 001.jpg .... 999.jpg:

ffmpeg -r 10 -b 1800 -i %03d.jpg test1800.mp4

You can mux streams (audio and video) like (add relevant codec options for bitrate, etc)

ffmpeg -i video.mp4 -i audio.wav -map 1.1 -map 2.1 output.mp4

I'm not going to go into more detail, as ffmpeg is a pain (args change in incompatible ways between versions, and depending on how it was compiled), and finding a rate/compression/resolution setting that is good for you is trial-and-error.