Capture FFMPEG output Capture FFMPEG output php php

Capture FFMPEG output


The problem is you catch only stdout and not stderr (see Standard Streams).Change this line:

$command = "/usr/bin/ffmpeg -i " . $src;

into

$command = "/usr/bin/ffmpeg -i " . $src . " 2>&1";

and give it another try :)


Use ffprobe instead, it's much quicker and supports JSON output.

$output = shell_exec('ffprobe -v quiet -print_format json -show_format -show_streams "path/to/yourfile.ext"');$parsed = json_decode($output, true);

And you have all your video info in a php array! This is much faster than ffmpeg -i for some reason.


To get output status and output:

exec("ffmpeg -i input.avi output.mp4 2>&1", $output, $returnStatus);print_r($output);if($returnStatus === 0){   // success}else {   //fail}