开发者

how to display ffmpeg error output

I am executing certain code through ffmpeg to encode avi files to flv. My ffmpeg c开发者_如何学Code is correct and is working fine, but when some error occurs (suppose it is a corrupted avi file, ffmpeg will not encode it), so i want to know what the error is. Here is a sample code:

$v_cmd=" some code to transcode";
exec($v_cmd,$v_output,$v_status);
if($v_status == 0)
{
echo "Success!";
}
else 
{
echo "ERROR: ".$v_output;
}

But this $v_output is just showing up as ERROR: Array ... i tried

echo "ERROR: ".implode($v_output);

but it was blank... how can i get the error message that ffmpeg gave so that i can understand what went wrong. This is a php cron script and it is not run in command line manually.


In POSIX-compliant systems and applications, errors will be sent to STDERR, not STDOUT. exec will only populate the $output argument with STDOUT:

exec("foo", $output);
var_dump($output);

Displays:

array(0) {
}

You have to redirect STDERR to STDOUT if you want this to work. Per example, on *nix:

exec("foo 2>&1", $output);
var_dump($output);

Will display:

array(1) {
  [0]=>
  string(18) "sh: foo: not found"
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜