CodySnider.com
| Main Menu | |||||||
|---|---|---|---|---|---|---|---|
|
| Guides | ||||
|---|---|---|---|---|
|
| Myspace Tools | ||
|---|---|---|
|
| Latest Articles |
|---|
| Statistics |
|---|
|
Members: 89 Articles: 130 Visitors: 175586 |
| Login |
|---|
| Encoding FLV on a Web Server |
|
|
|
|
So, as I’ve written in an earlier article on how to install FFMPEG on your server, while there are those who probably use a “YouTube Clone” script, there might be those who want to create their own using FFMPEG & PHP. FLV is the most widely used type of codec that runs on most Flash players.
So, let’s get started, there are actually a few steps into converting a file to FLV which are shown below 1. Send the script to FFMPEG-PHP and get it’s info We’ll start out our code with getting our variables: // Set our source file // Create our FFMPEG-PHP class // Save our needed variables Also, the width/height has to be multiples of two so I have created a function that makes it a multiple of two: function makeMultipleTwo ($value) if($sType == "integer") 2. Send the script to FFMPEG for encoding ffmpeg -i video.avi -ar 22050 -ab 32 -f flv -s 320x240 video.flv That’s generally how to convert a video.avi to video.flv with the audio sampling at 22050 & audio bit rate at 32, with the size 320×240. While I suggest the values above for audio as they are the most compressed, but we’ll use the old audio settings for better quality. $srcAB = intval($ffmpegObj->getAudioBitRate()/1000); Now we have pretty much most of the values ready for our compression, however, we need to call flvtool2 to get our Meta information. Steps 4 and 5 in the diagram work simultaneously with this one. What we do is make flvtool2 run at the same time as FFMPEG so we’ll pipe it into the command which means our general command is ffmpeg -i video.avi -ar 22050 -ab 32 -f flv -s 320x240 video.flv | flvtool2 -U stdin video.flv Now, we have a kind of complete command, let’s make our final code! <?php |



