Welcome to the Webmaster Forum.
+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 17
  1. #1
    Join Date
    Mar 2010
    Posts
    10
    Rep Power
    0

    Default convert video format to .flv(flash format) using php script

    convert video format to .flv(flash format) using php script

    Hi,



    i am a php programmer,I want to paly the video in my php site.I used the html object to play the video.But the user can upload any formated video(like .avi,mpeg,wmv).so for compatability i want to convert this formated video into .flv format(flash format) when they uploading.Does anyone know how to conert the vdieo using php script.my server is windeos server and php 5 version.

    thank u.

  2. #2
    Join Date
    Mar 2010
    Posts
    120
    Rep Power
    0

    Default

    ffmpeg is the key. Here is how to use it to produce flv:

    http://www.db75.com/blog/archives/000025.html

    You can call ffmpeg from php by using system function.

  3. #3
    Join Date
    Mar 2010
    Posts
    10
    Rep Power
    0

    Default

    thanks for reply....

  4. #4
    Join Date
    Mar 2010
    Posts
    120
    Rep Power
    0

    Default

    Sorry. I missed the part about Windows. There are tutorials on how to build ffmpeg under Windows:
    http://arrozcru.no-ip.org/ffmpeg_wiki/tiki-index.php. But it sounds rather complicated.

    I'm much more acquainted with Linux that Windows, so I probably can't help you to find Windows specific software.

  5. #5
    Join Date
    Mar 2010
    Posts
    120
    Rep Power
    0

    Default

    How to call system function?

    hi,

    i want to create a site that someone can download and convert directly.

    http://vixy.net/flv_converter
    i would like to ask on how you call the function of the engine...

    how do i put thing exactly like http://vixy.net/flv_converter,
    and when i click start, it convert by itself...

    i know to compile using gcc.
    what i want to know is to call the function using php.

    thanks in advance.

  6. #6
    Join Date
    Mar 2010
    Posts
    120
    Rep Power
    0

    Default

    audio for ffmpeg

    hello,
    i am working on an unix server where i am able to convert my video file into an flv format but the audio is nt available in the converted file can u tell me what would be the problem

    php file
    --------
    <?php
    class media_handler
    {
    function convert_media($filename, $rootpath, $inputpath, $outputpath, $width, $height, $bitrate, $samplingrate)
    {
    $outfile = "";
    // root directory path, where FFMPEG folder exist in your application.
    $rPath = $rootpath."\ffmpeg";
    // which shows FFMPEG folder exist on the root.
    // Set Media Size that is width and hieght
    $size = $width."x".$height;
    // remove origination extension from file adn add .flv extension, becuase we must give output file name to ffmpeg command.
    $outfile =$filename;
    $out=explode(".",$outfile);


    // Media Size
    //$size = Width & "x" & Height;

    // remove origination extenstion from file and add .flv extension , becuase we must give output filename to ffmpeg command.

    $outfile = $out[0].".flv";
    // Use exec command to access command prompt to execute the following FFMPEG Command and convert video to flv format.

    $ffmpegcmd1 = "/usr/local/bin/ffmpeg -i ".$inputpath."/".$filename. " -ar " .$samplingrate." -ab ".$bitrate." -f flv -s ".$size." ".$outputpath."/".$outfile;

    //$ffmpegcmd1 = "/usr/local/bin/ffmpeg -i ".$inputpath."/".$filename. " -b 500 -r 25 -s 320×240 -hq -deinterlace -ab 56 -ar 22050 -ac 1 ".$outputpath."/".$outfile." 2>&1";


    $ret = shell_exec($ffmpegcmd1);

    // return output file name for other operations
    return $ffmpegcmd1;
    }
    function grab_image($filename, $rootpath, $inputpath,$outputpath, $no_of_thumbs, $frame_number, $image_format, $width, $height)
    {
    // root directory path
    $_rootpath = $rootpath."\ffmpeg";
    // Media Size
    $size = $width."x".$height;

    // I am using static image, you can dynamic it with your own choice.
    $out=explode(".",$filename);

    $outfile = $out[0].".jpg";

    $ffmpegcmd1 = "/usr/local/bin/ffmpeg -i ".$inputpath."/".$filename." -vframes ".$no_of_thumbs." -ss 00:00:03 -an -vcodec ". $image_format." -f rawvideo -s ".$size. " ". $outputpath."/".$outfile;

    $ret = shell_exec($ffmpegcmd1);

    // Execute this command using exec command or any other tool to grab image from converted flv file.
    return $ffmpegcmd1;
    }
    }
    ?>

    i am using this for converison ...................
    can u help me out.......
    thanku

  7. #7
    Join Date
    Mar 2010
    Posts
    120
    Rep Power
    0

    Default

    sridivya, if you would only look into the help for ffmpeg

    it says:

    Audio options:
    -aframes number set the number of audio frames to record
    -ab bitrate set audio bitrate (in kbit/s)
    -ar rate set audio sampling rate (in Hz)
    -ac channels set number of audio channels
    -an disable audio
    -acodec codec force audio codec ('copy' to copy stream)
    -vol volume change audio volume (256=normal)


    so, remove -an from your params list, and it will work

  8. #8
    Join Date
    Mar 2010
    Posts
    120
    Rep Power
    0

    Default

    Theres also the FFmpeg extension for PHP.

    http://www.ffmpeg-php.sourceforge.net/

  9. #9
    Join Date
    Mar 2010
    Posts
    120
    Rep Power
    0

    Default

    ffmpeg is the key. Here is how to use it to produce flv:

    http://www.db75.com/blog/archives/000025.html

    You can call ffmpeg from php by using system() function.
    Reply With Quote

    Nice share.

    Thank you

  10. #10
    Join Date
    Mar 2010
    Posts
    120
    Rep Power
    0

    Default

    Convert video to flv using PHP FFMPEG
    Here is my code it will convert to flv but size can be 0KB. ANy one HELp????

    <?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!!!";
    }

    ?>


 

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
Back to top