In fact, video conversion on the server side is done by other softwares. PHP itself is used as a medium for the task maximum times.
We have a nice command line tool named “ffmpeg” to convert videos. I am currently working on a youtube video conversion tool and using ffmpeg to convert the videos from “.flv” to my desired format.
On my linux machine this simple command is enough to convert a “.flv” video to “.mpg” :
1 |
ffmpeg -i input_file.flv output_file.mpg |
Using php, I do the same. PHP has a function shell_exec() that lets you execute any shell command from PHP. So, this is what I do from PHP:
1 2 3 |
<?php shell_exec("ffmpeg -i input_file.flv output_file.mpg"); ?> |
That does the job for me 🙂