开发者

Create Video File using PHP

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 开发者_如何学Goallow to create a video.


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.


Under Ubuntu you need PHP5, ffmpeg and access to ffmpeg binary, this can be easy achieved with:

apt-get install php5 ffmpeg

I'm using this php function to generate an mp4 video from one gif image and one mp3 file, both source image and output video files are 720x576 pixels:

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);
}

example use:

$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);


Phil's solution is the correct approach. Work out what needs to be done by documenting yourself on ffmpeg (it's messy, and I can't blame him for not wanting to do your homework), and then call it from within php.

Cursory googling reveals php wrappers (e.g. http://ffmpeg-php.sourceforge.net/). If none are recent/complete enough, stick to issuing the needed shell commands from php.


ImageMagick convert -delay 100 -quality 75 photo1.jpg photo2.jpg movie.mpg

Or

http://dvd-slideshow.sourceforge.net/wiki/Main_Page
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜