Search code examples
phpflvwmv

PHP: FLV to WMV conversion


How can I convert FLV to WMV? Is there any script around there or some way I can integrate this?

Thank you!!!


Solution

  • I don't think you can do this directly with PHP. But, you can use external tools called form PHP (ffmpeg for example).

    Here is a code sample:

    <?php
    
    $src = "file.flv";
    $output = "file.wmv";
    ffmpegPath = "/path/to/ffmpeg";
    $flvtool2Path = "/path/to/flvtool2";
    
    $ffmpegObj = new ffmpeg_movie($src);
    
    $srcWidth = makeMultipleTwo($ffmpegObj->getFrameWidth());
    $srcHeight = makeMultipleTwo($ffmpegObj->getFrameHeight());
    $srcFPS = $ffmpegObj->getFrameRate();
    $srcAB = intval($ffmpegObj->getAudioBitRate()/1000);
    $srcAR = $ffmpegObj->getAudioSampleRate();
    
    exec($ffmpegPath . " -i " . $src . " -ar " . $srcAR . " -ab " . $srcAB . " -vcodec wmv1 -acodec adpcm_ima_wav -s " . $srcWidth . "x" . $srcHeight . " " . $output. " | " . $flvtool2Path . " -U stdin " . $output);
    
    // Make multiples function
    function makeMultipleTwo ($value)
    {
    $sType = gettype($value/2);
    if($sType == "integer")
    {
    return $value;
    } else {
    return ($value-1);
    }
    }
    ?>
    

    Sources:

    http://vexxhost.com/blog/2007/05/20/how-to-convertencode-files-to-flv-using-ffmpeg-php/ http://ubuntuforums.org/showpost.php?p=7315615&postcount=10