FFMPEG running in Command Line but not PHP

前端 未结 6 1161
-上瘾入骨i
-上瘾入骨i 2021-01-04 18:46

I am using ffmpeg build for windows to make video thumbnails . The command works well in command line but not from PHP exec method. am using PHP 5.2.11

Here is the c

相关标签:
6条回答
  • 2021-01-04 18:48

    I use it this way::

    exec("C:/wamp/bin/ffmpeg -i ./output4.mp4 -sameq -acodec libmp3lame -ar 22050 -ab 32 -f flv -s 320x240 ./output8.flv -vcodec mjpeg -vframes 4 -an -f rawvideo -s 320x240 ./pic008.jpg 2>&1");
    

    Directly connected from WAMP SERVER.

    Notice the:

    ./output4.mp4

    That tells PHP that I am dealing with the current directory.

    --All the Best

    0 讨论(0)
  • 2021-01-04 18:57
    exec("\"E:\\Documents and Settings\\x\\WINDOWS\\ffmpeg\" -i <inputfile> <options> <outfile>");
    

    Here's one of mine I've used in the past (granted I'm on a LAMP stack):

    $cmd = "/usr/bin/ffmpeg -i ".$in." -y -an -sameq -vframes 1 -s 100x56 -ss 3 -t 0.001 ".$out;
    

    You may also consider: http://ffmpeg-php.sourceforge.net/

    0 讨论(0)
  • 2021-01-04 19:00

    The error message says it doesn't recognize it as a command. Its most probably your quoting. Check your quoting of white spaces. Escape the white spaces when necessary using slash "\ ". And where is your code snippet that calls exec()?

    0 讨论(0)
  • 2021-01-04 19:02

    You need to escape your command properly:

    exec(escapeshellcmd($cmd), $thumb_stdout, $retval);
    

    Also do you have PHP safe mode on? You should check that $in is a real file before trying to encode too.

    0 讨论(0)
  • 2021-01-04 19:07

    are you properly escaping your backslashes, quotes etc.? Is there any error message?

    0 讨论(0)
  • 2021-01-04 19:08

    Maybe try this:

    $cmd = "\"$path\" -itsoffset -4 -i \"$in\" -vcodec mjpeg -vframes 1 -an -f rawvideo -s 320x240 \"$out\" 2>&1";
    
    0 讨论(0)
提交回复
热议问题