Converting Videos Using PHP

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” :

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:

<?php
shell_exec("ffmpeg -i input_file.flv output_file.mpg");
?>

That does the job for me :)

Tags: , . Bookmark the permalink.

Leave a Reply

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

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">