how to convert video to flv using php

Tutorial for how to convert video to flv using php. Most of video upload sites are using the ffmpeg and php for uploading and converting the video files.  For converting you need to install the ffmpeg on your server. you can download and install ffmpeg from following location.

how to convert video to flv using php

how to convert video to flv using php

how to convert video to flv using php

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

For installting the ffmpeg on linux box I found following article very helpful

http://mysql-apache-php.com/ffmpeg-install.htm

After installing the ffmpeg on your system you can use following commands for converting the video files to flv format.

avi to flv convert through ffmpeg

ffmpeg -i 00138.avi  -ab 56 -ar 44100 -b 200 -r 15 -s 320x240 -f flv final.flv

For creating the thumbnail the from video file you can use the folowing command.

create thubnail from movie file
ffmpeg -y -i moviefile.avi -vframes 1 -ss 00:01:60 -an -vcodec png -f rawvideo -s 110×90 new.png

In PHP you can use the following code easily.


$video_file = '/pathtovideo/test.avi';

$flvfile ='/pathtoflv/test.flv';

$png_path ='/pathtopng/test.png';

exec("ffmpeg -i ".$video_file."  -ab 56 -ar 44100 -b 200 -r 15 -s 320x240 -f flv ".$flvfile.");

//for thumbnail

exec("ffmpeg -y -i ".$video_file." -vframes 1 -ss 00:01:60 -an -vcodec png -f rawvideo -s 110x90 ".$png_path.");

Above code with convert the video file to flv format but my suggestion is convertion of video files will take so much bandwidth on server so use cronjob for converting the video files in night time.

Add a Comment

Your email address will not be published. Required fields are marked *