MP4Box in PHP

Discussion in 'PHP' started by cavendano, Aug 14, 2010.

  1. #1
    MP4Box will run its course if I use the command lines on a ssh client but if I set it up on a php script it will not run

    example:
    exec(/usr/local/bin/MP4Box -hint /home/myusername/public_html/2.3gp);

    no error message is given
    I have tried exec, passthru, and shell_exec.

    My php scripts are being run as user "nobody" and im root when I run it through the ssh client.

    Any advice would be great!
     
    cavendano, Aug 14, 2010 IP
  2. Rainulf

    Rainulf Active Member

    Messages:
    373
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    85
    #2
    Just what are you trying to achieve?

    All PHP scripts should be not root because that's the default and that's how it should be.

    Try:
    
    shell_exec('/usr/local/bin/MP4Box -hint /home/myusername/public_html/2.3gp');
    
    PHP:
     
    Rainulf, Aug 14, 2010 IP
  3. gapz101

    gapz101 Well-Known Member

    Messages:
    524
    Likes Received:
    8
    Best Answers:
    2
    Trophy Points:
    150
    #3
    try to check if you can execute mp4box using apache account
     
    gapz101, Aug 14, 2010 IP
  4. cavendano

    cavendano Well-Known Member

    Messages:
    360
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    130
    #4
    i am trying to setup a video hosting site that will offer support for mobile devices as well....
    I have everything down the conversion goes well and everything works if i do it on a shell client but wont work if I do it through PHP.

    so meaning that if the site takes off I would have to do the hinting manually rather than it being done automatically when the user uploads a video.
     
    cavendano, Aug 14, 2010 IP
  5. Kaizoku

    Kaizoku Well-Known Member

    Messages:
    1,261
    Likes Received:
    20
    Best Answers:
    1
    Trophy Points:
    105
    #5
    chmod +x /usr/local/bin/MP4Box

    should give executable to all
     
    Kaizoku, Aug 14, 2010 IP
  6. transparencia

    transparencia Peon

    Messages:
    27
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    I'm having the same exact problem and chmod +x /usr/local/bin/MP4Box didn't work.

    Any more suggestions?
     
    transparencia, Mar 30, 2011 IP
  7. bw_

    bw_ Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Hi...I was just about to post here because I had the exact same problem. However, I found the answer here: http://www.redkawa.com/forums/archive/index.php/t-518.html

    Additional to -hint you also need to use -tmp and enter the directory of the file you are writing to. This causes all temporary data from MP4Box to be saved in that directory instead of the root directory (that it can't access). This command then worked for me:

    shell_exec('/usr/bin/MP4Box -tmp '.$output.' -hint '.$output.'/movie.mp4');
    PHP:
    Hope it works for you too...
     
    bw_, Apr 1, 2011 IP
  8. transparencia

    transparencia Peon

    Messages:
    27
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    bw_ thank you so much for the reply but still it doesn't work!

    Also, do you have any idea on how to see what is the error that it's being displayed? I mean, I'm using error_reporting=E_ALL | E_STRICT and still it is not displaying any error. I know it is not working because the videos are not progressive. And MP4Box is working perfectly through the terminal with exactly the same instruction used in php exec()!

    Man this is crazy!
     
    transparencia, Apr 1, 2011 IP
  9. bw_

    bw_ Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Well, what I tried at first was a test php-doc that simply contained
    echo shell_exec('/usr/bin/MP4Box -hint '.$output.'/movie.mp4');
    PHP:
    When accessing this file over the web browser, it echoed some text and in the end said Error: I/O Error. Now that everything works it still echoes a bunch of info on the hinting process. Maybe you can gain some insight trying that...
     
    bw_, Apr 1, 2011 IP
  10. transparencia

    transparencia Peon

    Messages:
    27
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    That's the thing, if I do that there is no output on the browser. Completely blank... Although if I do for example exec("uptime"); it correctly shows the uptime.

    What could be the problem? I already chown the usr/local/bin to apache.
     
    transparencia, Apr 1, 2011 IP
  11. bw_

    bw_ Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    sorry for the late reply...try an additional echo before and after your line with shell_exec, are both displayed in the browser? is display_errors and all error reporting activated in your php.ini? also, the command posted by Kaizoku may not work if MP4Box is in another directory. For me it was chmod +x /usr/bin/MP4Box...
     
    bw_, Apr 6, 2011 IP
  12. transparencia

    transparencia Peon

    Messages:
    27
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #12
    bw_ Thanks man, it is solved!!

    Also, the reason it was not giving any output is because it exec needs to be like this exec("program 2>&1",$output) and then print_r($output) other wise it doesn't print anything!!

    Thank you all very much, especially you bw_!
     
    transparencia, Apr 6, 2011 IP