1

I am confused with instruction to install ffmpeg-php for video converting... There are some guide us to download and put files in particular folder and then convert files, but some instruct through another way, where you must download ffmpeg.exe and place it local and then call it from php to convert file.....

So which one is the best and how to install it....?????

Now i download ffmpeg and execute this script but not working, and give rights also...

$ffmpeg = "ffmpeg/ffmpeg.exe";
$desvfile = $_POST['file'];
$curr_dir = dirname(__FILE__);
$flvfile = $curr_dir."/converted/new1.flv";

if(file_exists($ffmpeg)){
    $cmd = "ffmpeg/ffmpeg.exe -i ".$desvfile." -ar 22050 -ab 32 -f flv -s 320×240 ".$flvfile; 
    exec($cmd, $output); 
    echo "executed command: [".$cmd."] with result: ".print_r($output, true)."<br>\n";
    echo "Successfully video Converted, to video.flv";
}
else{
    echo "There is some problem during converting!";
}

There is any way, to test => exec(ffmpeg) functionality....?????

UPDATED!

if(file_exists($desvfile)){
    echo "Destination file Exist. <br />";
    $cmd = "$ffmpeg -i '$desvfile' -ar 22050 -ab 32 -f flv -s 320×240 '$flvfile'"; 
    exec(escapeshellcmd($cmd), $output); 
    echo "executed command: => [".$cmd."] <br />with result: => ".print_r($output, true)."<br>\n";
    echo "Successfully video Converted, to video_converted.flv";
 }
else{
    echo "There is some problem during converting!";exit;
}

Which give me the output,,, but not execute the video to convert....

Output:

// Destination file Exist.

// executed command: => [/var/www/html/test_site/converter/ffmpeg/ffmpeg.exe -i '/var/www/html/test_site/converter/uploads/Gazzump.com - YouTube - Anders And.avi' -ar 22050 -ab 32 -f flv -s 320×240 '/var/www/html/test_site/converter/converted/new1.flv']

// with result: => Array ( )

// Successfully video Converted, to video_converted.flv
Community
  • 1
  • 1
Imran Khan
  • 2,373
  • 2
  • 22
  • 35
  • 1
    Gee, I wonder why. No, not really, it looks like you're trying to run a Windows executable in Linux. Which will of course not work (yeah yeah, Wine exists but who would be so crazy to run an executable in Wine when you've got native support on Linux). So : just install the ffmpeg package for your Linux distribution and it should work. – wimvds May 20 '11 at 12:18
  • @wimvds, yes i also know that there is some thing to O.S issue,, but i can't recognize and no idea to solve it. would you like to give me instruction for running on ubunto... this script... – Imran Khan May 20 '11 at 12:26
  • On Ubuntu, issue `sudo apt-get install ffmpeg` (on the cli), that should install ffmpeg (provided that you enabled the Universe and Multiverse repo's). Then you should be able to just use `exec('ffmpeg -i ... ');` to transcode a file. For more info (ie. to install extra codecs that are missing from the standard build), refer to the [Ubuntu Wiki - ffmpeg](https://wiki.ubuntu.com/ffmpeg) page. – wimvds May 20 '11 at 12:50
  • @wimvds, i follow ur steps but still not working, while ffmpeg is installed from cli... – Imran Khan May 24 '11 at 11:48
  • Then ffmpeg is not located in the path of the webuser, so either add that path to the PATH var of the webuser or specify the full path when calling `exec`. To locate ffmpeg just execute `which ffmpeg` from cli. – wimvds May 24 '11 at 12:30
  • by executing command: which ffmpeg.. give me /usr/bin/ffmpeg.... but stil not working when i add that path to the exec().. – Imran Khan May 24 '11 at 12:59
  • @wimvds, please read the above comments.. – Imran Khan May 25 '11 at 06:48
  • Then check if the webuser has write access to the folder/file you are providing for output. Or better yet, run your command from cli with the webuser and check for errors. – wimvds May 25 '11 at 07:02
  • @wimvds, i had give them chmod (777)..... and executing command in exec() are.... /user/bin/ffmpeg ....., then web path to source file.... same to destination folder... right....? – Imran Khan May 25 '11 at 07:10
  • @wimvds , yes usr... and the other method is right? – Imran Khan May 25 '11 at 07:41

1 Answers1

3

I've always found it easier to call FFMPEG with exec(). It is much easier to find exe builds of FFMPEG than the PHP extension. There is no install procedure for this method... just put the EXE somewhere on the server that is accessible by whatever account PHP is executing as.

There is no "best way" really. Both methods of accessing FFMPEG will produce the same output.

Brad
  • 159,648
  • 54
  • 349
  • 530
  • 1: Download a binary for FFMPEG (http://ffmpeg.zeranoe.com/builds/). 2: Copy ffmpeg.exe to some folder. 3: In your PHP script, call it using something like `exec("C:\somefolder\ffmpeg.exe someparameters");` – Brad May 12 '11 at 16:42
  • yes what i am expecting,, it is so easy..... but when i want to upload my site to server what to do...??? – Imran Khan May 12 '11 at 16:45
  • You do the same thing on your server. If this is shared hosting, then you need to ask your ISP to do it for you. You might be able to get away with uploading ffmpeg.exe to a folder within your web root and execute it from there, but usually the security restrictions don't allow this. – Brad May 12 '11 at 16:47
  • thank you very much, i am trying this method but to now no success, but i am sure i can do it.... and i will inform you tomorrow... – Imran Khan May 12 '11 at 17:22