Creating a video using PHP

I have a script to create video files using diff. such as images, audio file.

What I want to do is find the audio files from a specific folder and set them as background music, as well as get images from a specific folder and show them one at a time.

So basically I have images and audio files, and I want to create a video file using these resources using PHP.

Can anyone suggest a starting point for this? They captured images from video and converted the video using Ffmpeg, so I think about Ffmpeg, but I think it will not allow you to create video.

+8
php video-capture video-processing
source share
4 answers

ffmpeg will allow you to create video from still images.

For example, to create a video with a frame rate of 10 frames per second, from images 001.jpg .... 999.jpg:

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

You can use multimedia streams (audio and video), for example (add the appropriate codec parameters for bitrate, etc.)

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

I am not going to go into details, since ffmpeg is a pain (changes in incompatible versions between versions and depending on how they were compiled), and find the speed / compression / resolution parameter, which is good for you are a trial error.

+17
source share

In Ubuntu you will need PHP5, ffmpeg and access to the ffmpeg binary, this can be achieved with:

 apt-get install php5 ffmpeg 

I use this php function to generate mp4 video from one gif image and one mp3 file, and the original image and the output video files are 720x576 pixels in size:

 function mix_video($audio_file, $img_file, $video_file) { $mix = "ffmpeg -loop_input -i " . $img_file . " -i " . $audio_file . " -vcodec mpeg4 -s 720x576 -b 10k -r 1 -acodec copy -shortest " . $video_file; exec($mix); } 

usage example:

 $audio_file = "/path/to/mp3-file"; $img_file = "/path/to/img-file"; $video_file = "/path/to/video-file"; mix_video($audio_file, $img_file, $video_file); 
+5
source share

Phil's decision is the right approach. Find out what needs to be done by registering yourself with ffmpeg (this is messy and I can't blame him for not wanting to do his homework) and then call him from php.

Cursor googling shows php wrappers (e.g. http://ffmpeg-php.sourceforge.net/ ). If none of them is last / complete, stick to issuing the necessary shell commands from php.

+4
source share
 ImageMagick convert -delay 100 -quality 75 photo1.jpg photo2.jpg movie.mpg 

or

 http://dvd-slideshow.sourceforge.net/wiki/Main_Page 
+3
source share

All Articles