Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

Optimizing ffmpeg

For better quality



9:11 pm on Jul 1, 2010 (gmt 0)

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member

My video management skills are fairly amateur. I have a client shooting super high quality video with a commercial digital, encodes a 640x480 .wmv which he uploads to his site. It is encoded as .flv using ffmpeg, to be viewed with a Flash player (for various reasons.) Full screen *is* an option. The Flash player is exported for Flash 7 for backwards compatibility.

I set up and installed ffmpeg with some basic selectable settings. He uploads his .wmv, and the .wmv stays on the server but is used to re-encode as .flv. The cool thing here is he can re-encode the .flv as many times as he likes until he's happy with it without modifying or re-uploading the .wmv, which can be up to 300 MB in size. This all functions fairly perfectly.

He's happy with the .wmv quality, and "sorta okay" with the resulting .flv.

I need to get rid of the "sorta okay." :-) I have the following selectable options being passed to ffmpeg, and can add more if needed:

Frame Sizes
'480x320','480x360','640x480','800x600','852x480','1024x768','1600x1200' (They're leaving it at 640x480, default)

Audio Bitrate
7200,14400,28000,32000,64000,128000,256000 (defaults to 7200)

Video Bitrate
128000,200000,256000,384000,440000,512000 (defaults to 256000)

Audio Sampling
11025,22050,44100 (I read these are the only ones supported by Flash? defaults to 11025)

Frame Rate
9,15,20,25,30,35 (Defaults to 15)

I've no idea if any of these numbers are even good choices, or if, for example, one set needs to lock to another to be of any use.

So the questions are, what glaring options are missing from this list? What ranges for each would be a good set of selectable parameters for them to experiment with? Sacrifice of sound quality over video quality is their directive.


5:10 pm on Jul 2, 2010 (gmt 0)

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member

Corollary question asked today: I've no clue what H.264 is other than what I read on the Wiki, it's as vague to me as "Web 2.0." Does it have to be inherent in the video they create or can it be used in encoding to .flv? I do see ffmpeg has a library for it.


1:26 am on Jul 7, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

I'm not famialir with .flv but the same procipals apply with any codec. Any conversion especially going from one heavily compressed format to another heavily compressed format is going to cause some loss in quality. Loss when processing something like DV-AVI is minimal. The best thing to do is compress from the best source possible if that is an option. If you are going to need 5 different .flv's you'd start with the source for each conversion. Generally speaking WMV is not a great source since it's already been compressed, it's considered a distribution format and wasn't really intended for editing or reencoding. For example:

DV-AVI(native format of miniDV) >> 4000kbps MPEG2 = decent results

DV-AVI(native format of miniDV) >> 8000kbps MPEG2 >> 4000kbps MPEG2 = bad results

That extra step in between in the second example can really stomp on the quality. The more you step on it, the worse it gets.

Frame Sizes

Keep it the same or lower it if anything. See below becuase you video bitrate is relative to the frame size.

Audio Bitrate

Bitrate determines your file size, adjust this to your audience and content. If it's music video you'd probably want a higher bitrate. Speech can be lowered. Having said that 7200 which would be 7kbps would be far too low for almost anything in my book. "Crappy mp3's are even using 128kbps, the lowest I ever used on any audio was 22kbps mono track using WMA which excels at really low bitrates. The reason for the mono was I was looking for decent sound at really low bitrate, by dropping the stereo track I was able to halve the required bitrate. No stereo but it didn't sound like the music was being played inside a tin can either.

Video Bitrate

This is what you'll want to experiment with the most, start out high and work you're way dow until it becomes unacceptable. Each codec is going to have a sweet spot relative to the frame size. I'll use MPEG2 as an example as it is what I'm most familiar with. Generally speaking for well shot video on a tripod that is really clean anything over 8000kbps you're just making a larger file with no benefit. At 4000kbps macroblocking will start to appear, at that point you'll want to drop the frame size. You lose detail but will eliminate the marcoblocks. You also have to consider your content, if it's shaky video without a tripod that eats bitrate and you need to keep it higher. For example while a video shot on tripod from nice clean original DV-AVI might look great at 6000kbps if you have a capture from some old VHS without a tripod 9000kbps is going to be required.

Again I'm not familiar with .flv but I'd try the higher bitrates, this is where you'll see an improvement in the quality if any. Also keep in mind you're going to increase the file size as you increase the bitrate.

Frame Rate

The default from the camcorder is probably 30 but 15 is fine for web content, I've gone as low as 10 which is a little choppy. When you halve the frame rate you effectively halve the amount of bitrate required. I'd leave it 15.


1:55 am on Jul 7, 2010 (gmt 0)

WebmasterWorld Senior Member tangor is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

Videos? We don't need no steekin' videos!

(Merely joking... I'm waiting for a true across the board video standard and it just ain't there yet)


1:10 am on Jul 8, 2010 (gmt 0)

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member

<snicker> Which is why I've never bothered getting good at it, on the web, "good enough" is good enough . . . but this client sells video for a living, so it's become important. :-)

Was hoping you were still around coalman, this is all very helpful. The .flv can be re-encode as often as required until he's happy, but don't know if he can budge on the .wmv, will ask.

What say you about these numbers for video bitrates? They are passed directly to ffmpeg like so, I am *presuming* these are kbps, ex. 256000=256kbps.

128000,200000,256000,384000,440000,512000 (defaults to 256000)


8:15 am on Jul 8, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

Yes, they are just listing them as bits per second.

As far as getting him to budge from the WMV that probably isn't realistic. If he's doing video for a living he most certainly has a very high quality source however the file sizes are going to be enormous. 1 hour of SD miniDV is 14GB, same thing for HDV. Cams with the flash cards are going to be variable but probably around 10GB per hour.

If you want to get rid of the extra step he'd have to encode them client side to whatever you need instead of .wmv . That or switch to a silverlight player because it works with .wmv.


4:24 am on Jul 10, 2010 (gmt 0)

Hello, I installed the engine Dolphin, so they have a file ffmpeg
When I try to download the video, goes a mistake where it says, set the file ffmpeg
Maybe someone knows the answer?
Help please


10:32 pm on Oct 22, 2010 (gmt 0)

5+ Year Member

Hi rocknbil

I'd let them select to use the -sameq option which should produce results pretty close to the original (it sets the same quality settings on the decoder and encoder in the chain of filters it uses when doing the encoding pass). You can also configure 2 pass encoding which may help.

Featured Threads

Hot Threads This Week

Hot Threads This Month