1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

convert avi to flv

Discussion in 'PHP' started by Mariam, Oct 3, 2008.

  1. Mariam

    Mariam New Member

    Joined:
    Sep 9, 2007
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    0
    Hi.

    Please tell how can I convert avi to flv using PHP.

    Thanks a lot.
     
  2. pradeep

    pradeep Team Leader

    Joined:
    Apr 4, 2005
    Messages:
    1,646
    Likes Received:
    86
    Trophy Points:
    0
    Occupation:
    Programmer
    Location:
    Kolkata, India
    Home Page:
    Install FFMPEG and running the ffmpeg -i test.avi -ab 56 -ar 22050 -b 500 -r 15 -s 320x240 test.flv command using the shell_exec function in PHP.

    PHP:
     // Source file (uploaded file using http upload)
     
    $src $_FILES['video']['tmp_name'];
     
     
    // Destination FLV
     
    $dest '/path/to/your/videos/myvideo.flv';
     
     
    // Command to encode movie to flash video
     // use escapeshellcmd to make the command safe
     
    $command escapeshellcmd('ffmpeg -i ' $src ' -ab 56 -ar 22050 -b 500 -r 15 -s 320x240 ' $dest);
     
     
    // Execute the command
     
    shell_exec($command);
     
     
  3. abu123

    abu123 New Member

    Joined:
    Dec 1, 2009
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Here is my code,
    PHP:
    <?php
    function makeMultipleTwo ($value){
    $sType gettype($value/2);
    if(
    $sType == "integer"){
    return 
    $value;
    } else {
    return (
    $value-1);
    }
    }

    $srcFile "kabhi-alvida.avi";
    $destFile ".flvs/kabhi-alvida.flv";
    $ffmpegPath "/usr/local/bin/ffmpeg";
    $flvtool2Path "/usr/local/bin/flvtool2";


    $ffmpegObj = new ffmpeg_movie($srcFile);


    $srcWidth makeMultipleTwo($ffmpegObj->getFrameWidth());
    $srcHeight makeMultipleTwo($ffmpegObj->getFrameHeight());
    $srcFPS $ffmpegObj->getFrameRate();
    $srcAB intval($ffmpegObj->getAudioBitRate()/1000);
    $srcAR $ffmpegObj->getAudioSampleRate();


    $command $ffmpegPath " -i " $srcFile " -ar " $srcAR " -ab " $srcAB " -f flv -s " $srcWidth "x" $srcHeight " " $destFile " | " $flvtool2Path " -U stdin " $destFile;
    $convert exec($command);



    if(!
    $convert){
    echo 
    "FAILED!!!";
    }

    ?>
    What's wrog with this. everything going okey, but output flv file is 0kb. Plz help
     
    Last edited by a moderator: Dec 1, 2009
  4. dasli

    dasli New Member

    Joined:
    Aug 13, 2009
    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    0
    as for me I convert with Video to Flash Converter
     
  5. Iliya

    Iliya New Member

    Joined:
    Apr 15, 2010
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    I prefer use the program Flash to Video Encoder, to me has very much helped.
     

Share This Page