Run commandline in php file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sarayu
    New Member
    • Jul 2008
    • 15

    Run commandline in php file

    Hi,
    I am converting the video files to .flv using ffmpeg.I run and i converted all the files to .flv format in cmd.But how can i call the cmd commands in my php file.I used exec for conversion like this.But it wont be converted.Pleas e help me about this,

    Thanks in advance
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    What do you mean by "it wont be converted"?

    The exec function should allow you to execute any command, assuming the user running PHP has permission to execute it.

    Comment

    • sarayu
      New Member
      • Jul 2008
      • 15

      #3
      Hi Atli,

      I used ffmpeg for video conversion in windows.I converted those files to .flv format in cmd by using this command.

      C:\>ffmpeg -i sruthi.wmv -ar 22050 -ab 32 -f flv project/video.flv

      It converted to video.flv in my project directory.But when i call this command in my php file using exec like this

      $ffmpegPath="C://ffmpeg/ffmpeg.exe";
      $in="C://ffmpeg/sruthi.wmv";
      $out="C://ffmpeg/video1.flv";
      exec('$ffmpegPa th -i $in -ar 22050 -ab 32 -f flv -s 320×240 $out');
      When i want to execute like this nothing will be displayed.How can i call exec in my file.

      Comment

      • Markus
        Recognized Expert Expert
        • Jun 2007
        • 6092

        #4
        Originally posted by sarayu
        Hi Atli,

        I used ffmpeg for video conversion in windows.I converted those files to .flv format in cmd by using this command.

        C:\>ffmpeg -i sruthi.wmv -ar 22050 -ab 32 -f flv project/video.flv

        It converted to video.flv in my project directory.But when i call this command in my php file using exec like this

        $ffmpegPath="C://ffmpeg/ffmpeg.exe";
        $in="C://ffmpeg/sruthi.wmv";
        $out="C://ffmpeg/video1.flv";
        exec('$ffmpegPa th -i $in -ar 22050 -ab 32 -f flv -s 320×240 $out');
        When i want to execute like this nothing will be displayed.How can i call exec in my file.
        $variables aren't parsed inside single quotes ('). Try using double quotes or concatenating your variables.

        [php]
        exec($ffmpegPat h . ' -i ' . $in . ' -ar 22050 -ab 32 -f flv -s 320×240 ' . $out);
        [/php]

        Comment

        • sarayu
          New Member
          • Jul 2008
          • 15

          #5
          I tried using double quotes and concatenating also.But it does not work.Any other solution?

          Comment

          Working...