PDA

View Full Version : Need help tweaking FFmpeg settings...


Markstar
12th July 2006, 22:00
Hi,
I hope this is the right forum - I used search and most answers about FFmpeg where here even though I couldn't find any discussion about the program itself. :(

Anyway, here's the deal: Let's say I have 2 5-minute mpeg files. One, low.mpg, is 352*288, ~50MB and of rather bad quality. The other, high.mpg, is 720*576 with very good quality and ~160MB.

With FFmpeg, I want to get both files to around 30MB. This is what I've used for the first file which resulted in exactly the file I wanted:
ffmpeg -i low.mpg -vcodec msmpeg4 -vtag MP43 -s cif -b 800 -acodec mp3 -ab 64 low.avi

However, using the same settings for high.mpg, I get a heavily undersized file (~20MB instead of 30). :scared: Why? If anything, I expected the higher quality source to result in a bigger file but certainly not less! I've also tried "-vcodec xvid", which worked but also gave me a similar undersized file. :(

Next I tried two-pass-encoding since I assumed this would make it better while also further increasing the quality. These are the two commands I used:
ffmpeg -i high.mpg -vcodec msmpeg4 -vtag MP43 -s cif -b 800 -pass 1 -passlogfile high.log -acodec mp3 -ab 64 high.aviand
ffmpeg -i high.mpg -vcodec msmpeg4 -vtag MP43 -s cif -b 800 -pass 2 -passlogfile high.log -acodec mp3 -ab 64 high.avi
While it did create a logfile with plenty of stuff in it, in both passes it created the same undersized avi as before! :(

Some other (minor) things I don't understand are:
- Downloading the lated version of FFmpeg was a lot more difficult that I thought. The homepage refers to the to the MPlayer project and some svn page, both of which only have the source codes as far as I could tell. Googleing "ffmpeg download" resulted in many hits but most were dead ends or for linux. So I downloaded a version from here (http://www.free-codecs.com/download/ffmpegGUI.htm). Is that a "good" (stable, recent) version? Where does one usually get the compiled files?

- Also, the documentation (http://ffmpeg.mplayerhq.hu/ffmpeg-doc.html) lists all the supported codecs for encoding and decoding. But what are the appropriate switches???
For example, the table says FFmpeg supports MPEG-4 and that this is aka DivX4/5. But what is the right switch for it??? It's not MPEG-4, but it is neither MPEG4, MP4, divx5, divx4 nor divx. :(
And the one I used above, "-vcodec msmpeg4, I got from an example and don't even know if that is really DivX3 (I'm assuming it is but I'm not sure).

- The documentation also mentions a "-hq" switch to increase the quality but when I insert it it says "unrecognized option '-hq' ".


Anyway, my main problem is definitely the undersized file since I would like to set up a batch with many files and of course they should all have the same size/quality.

Thank you in advance for any help!!!

Manao
12th July 2006, 22:43
Hummm, how does that relate to h264/avc ? :)

Anyway, most probably, the high quality 5 minutes video was too easy to encode. Try to replace '-b 800' by '-qscale 2'. If the video has the same size ( 20 MB ), then that's the reason.

There are no single MPEG4 codec. There are codecs that implements the MPEG4 standard. Those codecs are DivX 4 ( in a buggy way iirc ), DivX 5 & 6, XviD, 3ivX, Nero,.... DivX 3 ( AKA msmpeg4 ) is not a MPEG4 codec. It's a microsoft codec that deviates a lot from the MPEG4 standard.

FFMpeg allows to use open source codecs ( XviD, lavc ), and some almost open source one ( DivX 4 ). What you want is to use either XviD ( -vcodec xvid ) or lavc ( -vcodec mpeg4 ). You might also want to use mencoder, which is more user friendly and does have a comprehensible documentation on the website ( in addition to easier to find binaries ).

foxyshadis
12th July 2006, 22:52
That's definitely fodder for " New and alternative video codecs " forum. And it is pretty insane to use anything related to MSMPG4, being over 7 years old now.

You should use as codec "mpeg4" or "xvid". And yes, that is a failing of the documentation. [Manao got here first! Hah.]

And yes, a better quality file can give smaller output while of the same quality, because it only has to compress real stuff, not random blocks and noise as well. You're probably getting undersizing because your files are just too compressible, and you're not touching any of the advanced settings to prevent that and allow extra quality. (Custom matrices especially.)

Why do you need a file of specific size? If you're maxing out the quality, why do you want a still larger file?

Markstar
12th July 2006, 23:59
Hummm, how does that relate to h264/avc ? :):( Well, umm, ... :o
I heard about FFmpeg for the first time today, searched the forum and as I said - most of the stuff was here.

Anyway, most probably, the high quality 5 minutes video was too easy to encode. Try to replace '-b 800' by '-qscale 2'. If the video has the same size ( 20 MB ), then that's the reason.Damn, I should have thought about this myself - rookie mistake. Yes, it does look like quality is maxed out. :cool:

There are no single MPEG4 codec. There are codecs that implements the MPEG4 standard. Those codecs are DivX 4 ( in a buggy way iirc ), DivX 5 & 6, XviD, 3ivX, Nero,.... DivX 3 ( AKA msmpeg4 ) is not a MPEG4 codec. It's a microsoft codec that deviates a lot from the MPEG4 standard.Yes, I know that but thanks for clarifying it again! What I wanted to know what the correct switch for DivX4/5/6 is since I couldn't find it in the documentation.

FFMpeg allows to use open source codecs ( XviD, lavc ), and some almost open source one ( DivX 4 ). What you want is to use either XviD ( -vcodec xvid ) or lavc ( -vcodec mpeg4 ). Yep, using XviD from now on. ;)

You might also want to use mencoder, which is more user friendly and does have a comprehensible documentation on the website ( in addition to easier to find binaries ).Hmm, already learned to use one program today which I'm pretty happy with and I think it is sufficient for what I have in mind. :D

Why do you need a file of specific size? If you're maxing out the quality, why do you want a still larger file?No, I don't need a specific size as long as the quality is as good as it gets with the size it has. :cool:

As I said, I simply forgot to make a run with the highest settings to check if the quality is maxed out. As an excuse I'd like to say that just before I posted this, I looked at my old posts, this one in particular (http://forum.doom9.org/showthread.php?t=103196) where I have the exact opposite problem where I get an oversized file but nobody could help me then. So I just assumed this might be another one of those things that don't make sense (at least to me) and I didn't think about this problem enough.

Anyway, still wondering why the first pass already produced an output file but other than that I think everything is settled - thank you guys, I really appreciate it!

bond
13th July 2006, 00:27
moved