Skip to main content
June 2, 2011
Question

ffmpeg and php video conversion

  • June 2, 2011
  • 1 reply
  • 203855 views

Hello

I have recently been trying to covert uploaded video into flv so that its playable on a flash player. I trying to use ffmpeg which is installed

on my hosting plan server.

I have been able to grab thumbnails using ffmpeg but now need to convert the video into flv. The code I have does a conversion but the

file is 0kb when its outputted to the Videos folder;

This is the code:

$src = "Videos/robot.avi";
$output = "Videos/robot.flv";
$ffmpegPath = "ffmpeg";
$flvtool2Path = "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);
}
}

I dont have flvtools but they are not nessary as they only collect meta data.

Thank you,

This topic has been closed for replies.

1 reply

adninjastrator
Inspiring
June 2, 2011

I've got a feeling that this topic may be a little out of place here.

Have you had a look at PHPMotion, a free, open source video upload/conversion/sharing script?

http://www.phpmotion.com/

You could download and take it apart to see how it works... it's free and won't cost you anything to at least look at it.

I use it on one of my sites for file conversion and it seems to work just fine.

Best wishes,

Adninjastrator

June 3, 2011

Hello

Thanks alot for the reply. I have check out the phpmotion it seems really good but I really need to use ffmpeg. The reason is I have a hosting plan that has ffmpeg installed on the server which works well with my exsisting code. I have already used ffmpeg to grab thumbnail every time some one uploads a file but now I just need to convert uploaded files into flv. The code I uploaded does that but the converted file for some reason is 0 kb when inside folder.


Thanks.

adninjastrator
Inspiring
June 3, 2011

PHPMotion is ffmpeg based and is open source.

My suggestion was to download the source code and see how they use it for file conversion.

Best wishes,

Adninjastrator