FFmpeg package for php

308 views Asked by At

Does simple ffmpeg package also work fine when we execute its command from PHP via exec? Or we have some different ffmpeg package for that purpose? Please help me solving it.

2

There are 2 answers

6
Shankar Narayana Damodaran On

Yes simple ffmpeg does work through PHP exec if you have necessary permissions.

Sample command

<?php

     /*** convert video to flash ***/
     exec("ffmpeg -i video.avi -ar 22050 -ab 32 -f flv -s 320x240 video.flv");

?>

Source

2
marekful On

PHP's ffmpeg and the vanilla ffmpeg are independent packages. The php5-ffmpeg package comes with the ffmpeg binary as a dynamic library. This means that you can install only php5-ffmeg without installing the command line ffmpeg package or vice versa or you can have both of them installed.

Therefore, the answer is yes, PHP will work with the command line ffmpeg given it is installed.

I usually prefer using the command line ffmpeg in PHP via exec. This allows for testing certain operations on the command line and once the result is as desired, the command can be used in PHP's exec. On the other hand, in some situations, it may be preferable to use the php5-ffmpeg package because it gives you the ability to use object oriented coding style when dealing with videos, conversion, etc.