Shoutbox

[split] encoding with MP4Box - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Skype & Technology (/forumdisplay.php?fid=9)
+---- Forum: Tech Talk (/forumdisplay.php?fid=17)
+----- Thread: [split] encoding with MP4Box (/showthread.php?tid=91291)

RE: FFMPEG-PHP: converting videos by Burbruee on 07-01-2009 at 05:16 AM

Hello, new member here. Found this by a search engine. :)
I'm trying to make uploading and converting on the serverside and encoding with mencoder through shell_exec work.
I also need to use MP4Box afterwards.

What I do is
1: encode with mencoder.
2: Split the video and audio with MP4Box.
3: Join the video again.

Else buffering won't work.

Anyway, I made some changes to the script posted here for h264, but some strange things are happening, or rather not happening.

The command I want to execute is "MP4Box -aviraw video file.avi"

code:
<?php
convertToMp4( "test.avi", "out" );

function convertToMp4( $input, $output ) {
    $input = escapeshellarg($input);
    $output = escapeshellarg($output);

    $command2 = "MP4Box -aviraw video $output";
    echo "$command2<br />";
    shell_exec( $command2 );
}

?>
I commented out the rest of the script for now so this is the only executed code.
I already have the menconded file in the directory.

Okay, so if I run this through my browser, the echo comes up with
code:
MP4Box -aviraw video 'out'
(out is the name of my testfile, yes it does not have an extension, and yes the name is misleading since MP4Box is asking for the input, but this is the "out" from mencoder..)
It creates no new file in the dir when run through the browser.. So it doesn't do anything at all.

However, if I were to run
code:
php convert.php

(through ssh via putty)
it all works! It demuxes the video part and out_video.h264 is created!
Why? Why does it not work in the browser?
Am I missing something? It's not a permission issue because mencoder worked through shell_exec...

Thanks for any help you may provide.
Never mind, after some work I got it working.
I'll post the solution in case somebody else may have the same problem.

I checked my error log for apache and it read
code:
sh: MP4Box: command not found

So I simply issued a 'whereis MP4Box' and found out it was located in /usr/local/bin, then in my .php I created a variable $mp4path where I put in the path.
So I use the following:
code:
$mp4path = "/usr/local/bin/"
$cmd = $mp4path . "MP4Box -aviraw video " . $output;
shell_exec( $cmd );