SitePoint Sponsor

User Tag List

Results 1 to 13 of 13
  1. #1
    SitePoint Member
    Join Date
    Dec 2006
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problems with shell_exec and exec

    I have two codes, the idea is to convert a video to flv with ffmpeg, using a php script.

    Code:
    <?php
    
    $output = shell_exec('ffmpeg -i unconverted/fg605.avi flv/fg605.flv');
    print_r($output);
    
    ?>
    outputs this:

    Code:
    ffmpeg version 0.4.9-pre1, build 4730, Copyright (c) 2000-2004 Fabrice Bellard configuration: i386-redhat-linux --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib --libexecdir=/usr/libexec --localstatedir=/var --sharedstatedir=/usr/com --mandir=/usr/share/man --infodir=/usr/share/info --extra-cflags=-O2 -march=i386 -mcpu=i686 --enable-mp3lame --enable-vorbis --enable-faad --enable-xvid --enable-pp --enable-shared-pp --enable-shared --enable-gpl --disable-strip built on Mar 10 2005 20:58:17, gcc: 2.96 20000731 (Red Hat Linux 7.3 2.96-113)
    The second code:
    Code:
    <?php
    $output = array();
    exec('ffmpeg -i unconverted/fg605.avi flv/fg605.flv', $output);
    print_r($output);
    
    ?>
    outputs this:
    Code:
    Array ( [0] => ffmpeg version 0.4.9-pre1, build 4730, Copyright (c) 2000-2004 Fabrice Bellard [1] => configuration: i386-redhat-linux --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib --libexecdir=/usr/libexec --localstatedir=/var --sharedstatedir=/usr/com --mandir=/usr/share/man --infodir=/usr/share/info --extra-cflags=-O2 -march=i386 -mcpu=i686 --enable-mp3lame --enable-vorbis --enable-faad --enable-xvid --enable-pp --enable-shared-pp --enable-shared --enable-gpl --disable-strip [2] => built on Mar 10 2005 20:58:17, gcc: 2.96 20000731 (Red Hat Linux 7.3 2.96-113) )
    As you can, see, they are both doing the same thing. The problem s that neither of them are writing the file (flv/fg605.flv) or giving me an output that is helpful.

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Have you tried using absolute paths for your two files? Could it be writing the file, just not where you expect it to be?

  3. #3
    SitePoint Member
    Join Date
    Dec 2006
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have tried the "absolute path" that I am given in my serverspace, but I know it's not the actual absolute path (/website.com/folder instead of /home/website.com/folder or whatever) But I have absolutely no access to folders beyond my own. I have also tried putting all the files in one folder and using no paths. Still doesn't work.

  4. #4
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Run phpinfo() and take a look at your DOCUMENT_ROOT or SCRIPT_FILENAME or any number of other variables to find your full path. Then specify the input and output files for ffmpeg with full paths.

  5. #5
    SitePoint Member
    Join Date
    Dec 2006
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, I tried that, found the absolute path and it still didn't work.

  6. #6
    SitePoint Evangelist ldivinag's Avatar
    Join Date
    Jan 2005
    Location
    N37 33* W122 3*
    Posts
    414
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    try running EXEC without the output option.

    see if that creates the file.
    leo d.

  7. #7
    SitePoint Member
    Join Date
    Dec 2006
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That did create an empty file. I'm getting closer I think

  8. #8
    SitePoint Member
    Join Date
    Dec 2006
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Use the absolute path to the ffmpeg executable, as well as any files you specify on the command line.

  9. #9
    SitePoint Member
    Join Date
    Dec 2006
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You don't really need to use an absolute path for anything inside the $PATH, and it was clearly running the program, it just creates an empty file.

  10. #10
    SitePoint Evangelist ldivinag's Avatar
    Join Date
    Jan 2005
    Location
    N37 33* W122 3*
    Posts
    414
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    do you have shell access?

    maybe that program is just crapping out and is just creating an empty file, even if you ran it from the command line...
    leo d.

  11. #11
    SitePoint Wizard stereofrog's Avatar
    Join Date
    Apr 2004
    Location
    germany
    Posts
    4,324
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Add "2>&1" to your command line and look what it says.

  12. #12
    SitePoint Member
    Join Date
    Dec 2006
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, this has now evolved into a problem with ffmpeg, [Thanks so much for the help this far!]

    This is the output now, it seems to think some terrible things about the input of the incoming file, I think that if I look up the tags for input and such it would fix it. I don't know anything about ffmpeg, but I will try this and see how it goes.

    Code:
    Input #0, asf, from '/hsphere/local/home/threefou/rollindependent.com/unconverted/3mik.asf': Duration: 00:00:30.0, start: 0.000310, bitrate: 102 kb/s Stream #0.0: Audio: wmav2, 16000 Hz, mono, 16 kb/s Stream #0.1: Video: msmpeg4, 176x144, 1.00 fps Output #0, flv, to '/hsphere/local/home/threefou/rollindependent.com/flv/fg6051.flv': Stream #0.0: Video: flv, 176x144, 1.00 fps, q=2-31, 200 kb/s Stream #0.1: Audio: mp3, 16000 Hz, mono, 64 kb/s Stream mapping: Stream #0.1 -> #0.0 Stream #0.0 -> #0.1 Could not write header for output file #0 (incorrect codec parameters ?)

  13. #13
    SitePoint Member
    Join Date
    Dec 2006
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Now, If I disable the audio (-an) It will give me a file of size, but when I try to play it in the flash player or browser, it is just a blank file of the correct video length, I still can't get audio working though.


Bookmarks

Posting Permissions

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