Friday, October 10, 2008

Video Conversion Dynamically Using FFMPEG,PHP

Every programmer has an idea to convert the video file types dynamically into any formats on the fly. They all know there is a tool called FFMPEG to convert video formats to their desired formats which they want. In this tutorial i'll let you know how to use the FFMPEG tool during file upload dynamically.

1. Download FFMPEG.EXE from here
2. Extract the FFMPEG.EXE from the archive.
3. Place the FFMPEG.EXE in the webdirectory.
4. As you all know how to upload a file (So i'm moving to the next step).
5. After the file uploaded just put the below line
exec("ffmpeg -i recipe_videos/$path -f flv recipe_videos/$test[0].flv");
//Format exec("ffmpeg -i pathofthevideouploaded -f towhichformat wherethefiletobesavedwithextension");
6. If you want delete the old file.
7. Now you can view the video in the desired format.

19 comments:

Anonymous said...

It worked on my localhost.
WIll it work on a linux server as well?

Anonymous said...

Which revision should i download to work on both linux and windows

Sathish Kumar said...

you can use the latest & stable exe file for both windows & linux version. In windows you must ask your service provider to allow executing the exe file. Because in most of the windows server the firewall will protect to not executing the exe file directly.

Anonymous said...

In step 4, please tell us where to put that line in.

Hope you replay soon.

Sathish Kumar said...

After move_uploaded_file you can put the exec("") command

Anonymous said...

i have no found ffmpeg-exe file anywhere. Can anyone help me?

Anonymous said...

i have no found ffmpeg-exe file anywhere. Can anyone help me?

Sathish Kumar said...

Hi,
You can download from this url:

http://www.videohelp.com/download/FFmpeg-0.5.1-svn-22140.7z

Anonymous said...

Thanks Satish for providing me ffmpeg url. I have download it.But script does not work on my localhost.
Can you provide me complete method of creating thumbs form videos using ffmpeg?
Please Provide me zip folder or complete code .

Anonymous said...

I am waiting for you reply.

Anonymous said...

exec("C:\Users\Alan\ffmpeg\ffmpeg\bin\ffmpeg -i C:\xampp\htdocs\Anarchists&Atheists\VideoUploads/$path -f flv C:\xampp\htdocs\Anarchists&Atheists\VideoUploads/$test[0].flv");
//Format exec("C:\Users\Alan\ffmpeg\ffmpeg\bin\ffmpeg -i pathofthevideouploaded -f towhichformat wherethefiletobesavedwithextension");

But I am confused as to where I put this?

Poonam said...

Hello Sir,I have used ffmpeg.exe ,
on localhost it is done but for small size video files.
means i have tried mp4 file having size 2.12MB to flv ,it did not work.
less than 2MB files are converted.

Please reply.

Sathish Kumar said...

Hi Poonam,
If you want to convert more than 2mb files then you've to increase upload_max_filesize & post_max_size
and also need to increase the max_execution_time in php.ini file. so that it can convert larger file size

Poonam said...

Thank You for reply
I have already increased upload_max_size,post_max_size and now i increased max_execution_time also
still video files are not converted
it only creates video file of flv type but with 0 byte size.

Anonymous said...

Dear sir
i am confusing in video convrte.I am using windows wamp and appache server
in localhost, i have done use lot of effort in video coneverion. video formate is convert successful but converted video can't play

please suggest me all step with some code windows xp appche localhost server video convert in upload and play all browser successfully

Thanks

Rajeev Chauhan said...

m trying several time to convert our video in mp4 formats (
exec("ffmpeg -i input.flv -f mp4 output.mp4");) and play in HTML5 but video convert successfully in mp4 but unable to play in html5 what i do ...?

Rajeev Chauhan said...

I have converted an flv video in mp4 using ffmpeg.but this not playing in html5.it is giving an error
"No video with supported MIME type found"
can anyone help ??

Naviya Nair said...

Great Article..
PHP Training in Chennai
Online PHP Training
Online PHP Training India
PHP Training Chennai
PHP Training institute in Chennai

Bhavya Kumar said...

My friend Suggest me this blog and I can say this is the best blog to get the basic knowledge.Thank you so much for this Selenium Training in Chennai