Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Aug 2008
    Location
    Hollywood, CA, USA
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Trouble with exec - silently doesn't run a program

    Thank you SO MUCH for your time in helping me.

    I'm trying to convert videos using ffmpeg, exec'd from a php page.
    I've created a shell script that uses all the ffmpeg options I want and takes 2 parameters for input filename and output filename. That shell script works properly when i run it from a shell.

    Here's the shell script
    Code:
    #!/bin/sh
    whoami
    date
    echo about to: ffmpeg -i $1 -ar 22050 -ab 32k -r 25 -s 320x240 -vcodec flv -qscale 9.5 $2
    #ffmpeg
    ffmpeg -i $1 -ar 22050 -ab 32k -r 25 -s 320x240 -vcodec flv -qscale 9.5 $2
    echo $?
    whoami
    (all but the big ffmpeg line is just debugging and curiousity)

    when I run it from within my php page by doing:
    PHP Code:
    echo exec"danffmpeg  $cFileName  $cFLVName", &$aExecOutput, &$nExecReturn );

    echo( 
    "<BR>execoutput:<BR>\r\n" );
    print_r$aExecOutput );
    echo( 
    "<BR>execreturn:<BR>\r\n" );
    print_r$nExecReturn ); 
    I get this output:
    apache

    execoutput: Array ( [0] => 0 [1] => apache [2] => Wed Aug 13 19:32:51 PDT 2008 [3] => about to: ffmpeg -i records/avitest_79.avi -ar 22050 -ab 32k -r 25 -s 320x240 -vcodec flv -qscale 9.5 streams/avitest_79.flv [4] => 1 [5] => apache )

    execreturn: 0
    The return value of ffmpeg within the script is 1, but the execreturn value of danffmpeg is 0.

    When I change the line in the shell script that launches ffmpeg -- I uncomment the unadorned #ffmpeg and comment out the one that includes all the parameters and actually tries to do the conversion...

    When I do that, ffmpeg runs. I can see the huge long help screen output in the execoutput. The $? return value of ffmpeg is still 1, and the execreturn value is still 0.

    This leads me to believe it's not a permissions problem of launching ffmpeg.
    My best guess is that it's not launching because of how much memory (or something) ffmpeg wants to take up when it tries to convert... and I tried setting memory_limit to 256M (from 16M) and it didn't change...

    It's an x86_64 system running CentOS 5
    I've attached my phpinfo output.

    Thank you again for your help
    dan
    Attached Files Attached Files

  • #2
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    add on top of the php script:
    PHP Code:
    ini_set('display_error',1);
    error_reporting(E_ALL); 
    read the server logs, must be something there,

    add a -x to shebang to be more chatty,
    Code:
    #!/bin/sh -x
    use this instead
    Code:
    togo=`ffmpeg -i $1 -ar 22050 -ab 32k -r 25 -s 320x240 -vcodec flv -qscale 9.5 $2`
    .....
    return $togo
    bash return exit code of the last executed command( I assume you don't really use sh, ).

    other problems could related to group/owner of the script, uid, gid.

    I hope this help you

    regards

  • #3
    New to the CF scene
    Join Date
    Aug 2008
    Location
    Hollywood, CA, USA
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    WOW! Thanks so much for your tips and tricks. you will have saved me 20 hours by the time the year is over.

    as it turns out, I'd just gotten the solution about when you were replying -- the output directory's group was apache and its ownership was 755. I'd read it, saw that the script was running as apache, saw that apache showed up in the line of ownership and didn't pay enough attention to correlate that the output directory wasn't writable. d'oh.

    but really - all three of those suggestions are awesome and going to improve my life.

    thank you

    dan

  • #4
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by burningdan View Post
    WOW! Thanks so much for your tips and tricks. you will have saved me 20 hours by the time the year is over.

    as it turns out, I'd just gotten the solution about when you were replying -- the output directory's group was apache and its ownership was 755. I'd read it, saw that the script was running as apache, saw that apache showed up in the line of ownership and didn't pay enough attention to correlate that the output directory wasn't writable. d'oh.

    but really - all three of those suggestions are awesome and going to improve my life.

    thank you

    dan
    you ar welcome,
    you can find some guide/howto's/intro on this link:

    http://www.tldp.org/

    'bash advanced guide', if I'm not wrong, anyway worst a look over all index,

    Edit: bash exit/code, I guess can be find in bash man page

    best regards
    Last edited by oesxyl; 08-14-2008 at 07:08 AM.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •