PHP & FFMPEG return output

623 views
Skip to first unread message

NabaisNet

unread,
Mar 31, 2008, 7:36:47 AM3/31/08
to ffmpeg-php
Hi there!

I'm trying to make a simple "if" to check if the ffmpeg encoding was
successfull. I've tried with exec, system, passthru, shell_exec and in
all the return variable is empty, or is an empty array.

I've even tried using stderr and stdout. I'm kinda desperate because
it's an important work...

Can anybody help me please ?

Thanks in advance

buggedcom

unread,
Mar 31, 2008, 4:24:08 PM3/31/08
to ffmpeg-php
exec('ffmpeg/binary/path -your -commands -here &> /path/to/temp/
file.info');

or alternativley use

http://www.phpclasses.org/browse/package/3747.html

buggedcom

unread,
Mar 31, 2008, 4:42:59 PM3/31/08
to ffmpeg-php
exec('ffmpeg/binary/path -your -commands -here &> /path/to/temp/
file.info');

or alternativley use

http://www.phpclasses.org/browse/package/3747.html

NabaisNet wrote:

Todd Kirby

unread,
Mar 31, 2008, 5:29:04 PM3/31/08
to ffmpe...@googlegroups.com
The third param to exec with give you the ffmpeg return code.

-T-

buggedcom

unread,
Apr 1, 2008, 5:16:46 AM4/1/08
to ffmpeg-php
Actually Todd, that doesn't work with ffmpeg. FFmpeg for some reason
doesn't return anything via any exec/passthru call from php.

buggedcom

unread,
Apr 1, 2008, 5:19:01 AM4/1/08
to ffmpeg-php
for example

exec(FFMPEG_BINARY.' -i '.$file, $output, $return);
var_dump($output, $return);
exit;

returns

array(0) { } int(1)

webm...@hpiracing.com

unread,
Apr 1, 2008, 11:47:34 AM4/1/08
to ffmpeg-php
Why not do this:

exec(FFMPEG_BINARY.' -i '.$file, $output, $return);

while(!is_file($output))
{
# waiting for completion
}

# rest of code

buggedcom

unread,
Apr 8, 2008, 3:29:04 AM4/8/08
to ffmpeg-php
because while the exec call is made php will not continue with the
rest of the code.

On Apr 1, 6:47 pm, "webmas...@hpiracing.com" <webmas...@hpiracing.com>
wrote:

webm...@hpiracing.com

unread,
Apr 8, 2008, 1:20:27 PM4/8/08
to ffmpeg-php
Wouldn't you have to wait until the exec call finishes anyway in order
to receive confirmation that the file was completely converted?

webm...@hpiracing.com

unread,
Apr 8, 2008, 1:39:25 PM4/8/08
to ffmpeg-php
I can see where that would have disadvantages if the file does not
complete. It's definitely set up for infinite loopiness. :P

You could also plug in a timeout.

<?PHP
function getTime()
{
list($usec, $sec) = explode(" ", microtime());
return (((float)$usec + (float)$sec) * 10000);
}

$limit = 1000;
$otime = getTime();

echo "Starting script.";
exec(FFMPEG_BINARY.' -i '.$file, $output, $return);

while(!is_file($output))
{
$ntime = getTime();
if($ntime >= $otime + $limit)
{
$timeout = 1;
break;
}
}

echo "Finished script.";
?>
Reply all
Reply to author
Forward
0 new messages