Running lame from php

这一生的挚爱 提交于 2019-12-06 07:44:23

Try something like this:

$output = array();
$result = -1;
exec('`/usr/bin/which lame` --help 2>&1', $output, $result);
var_dump($output, $result);

$output should be an array of lines contained in the output

$result should be an integer result code. 0 is typically success, >=1 is an error (specific codes are application dependant).

The 2>&1 part will redirect STDERR to STDOUT ($output) which would normally be dropped. So if it's erroring out, you should be able to see the error (hopefully).

If you get -1 for the dump of $result, there's a fundimental problem, because that's not a valid result code (it likely means that exec is disabled, or the process you're trying to run is restricted because of permissions errors or the such)...

If you feel a need for more convenient way to work with lame, I would recommend to use phplame wrapper. Install PHP LAME wrapper using Composer:

{
    "require": {
        "b-b3rn4rd/phplame": "dev-master"
    }
}

set error reporting on and check if you can do exec's. By default most systems wont allow it, it's a serious security liability. You've got to explicitly allow execs in php.ini.

Might be a $PATH problem. Try specifying the full path to lame, ie. /usr/local/bin/lame.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!