-   Linux - Software (
-   -   mencoder quality low (

gonniff 09-15-2003 10:13 AM

mencoder quality low
Dear All,

Ok, it's my first day here and my second thread, but this just occured to me.

I've been using mplayer and mencoder for less than a week and really like it on the whole. I'm using them on SuSE 8.2 on a really nice Compaq nx9005 with a whizzing 1.8GB processor and 256MB of RAM, so no really performance issues.

The question I have is this: I've tried using both 2 and 3 pass encoding of a couple of DVD's I borrowed from a friend, but find that the quality really isn't very good unless I crank up the bitrate to silly proportions (1800 plus) which then makes a 1.6GB file. Whew! Man, that's just too big! :)

I know nothing about video technology, so small steps (and small words) would be appreciated. The only thing that occurs to me is this: I have a couple of DivX's (avi's) from a friend and they are both in a much smaller, "letterbox" format and the clarity and resolution are perfect!

If I rescale the DVD's at rip time, will this go a long way toward improving quality and making the file sizes smaller? I'd like to keep the films to 2 CD's max.

Thanks in advance for all replies.


acid_kewpie 09-15-2003 10:26 AM

1) what commands are you using?

2) have you tried my program?

gonniff 09-15-2003 10:42 AM


Glad to see your reply! I've read some of your postings, so that's why I joined linuxquestions! (flattery, flattery).

I've just downloaded it and will give it a go when I get home.

Here are the commands I've used so far:

2 pass encoding:

mencoder -dvd 1 -ovc lavc -lavcopts vcodec=mpeg4:vpass=1 -oac copy -o movie.avi

mencoder -dvd 1 -ovc lavc -lavcopts vcodec=mpeg4:vpass=2 -oac copy -o movie.avi

3 pass option:

mencoder -dvd 1 -ovc frameno -oac mp3lame -lameopts vbr=3 -o frameno.avi

mencoder -dvd 1 -oac copy -ovc lavc -lavcopts vcodec=mpeg4:vpass=1:vbitrate=<bitrate>

mencoder -dvd 1 -oac copy -ovc lavc -lavcopts vcodec=mpeg4:vpass=2:vbitrate=<bitrate>

The quality until now (and I've only done two versions of one DVD - Buena Vista Social Club (100 minutes long) has been grainy and what I can only describe as "mosaic" - that is, blocky segments instead of clean, crisp resolution.

A colleague here at work reckons it's due to the file sizing itself just like it does when I play the DVD - a large square in the center of the screen rather than a nice, smaller "letterbox" shape.

The MEncoder docks say that resizing (rescaling) is a bad thing. Don't know what to try first, to be honest.


acid_kewpie 09-15-2003 10:51 AM

saliong isn't a problem really... in theory it's not as good, but hey... that's life. works fine for me.

add some extra options to lavcopts, e.g "vhq:vqmin=2". if you're going to encode manually, i'd suggest doing a -vop cropdetect before hand and whopping off any widescreen bands for extra quality.

i also habbitually resize to about 480 to 560 by whatever.... you really need to work out the average bits per pixel value, and aim to hit around 0.20 for a good divx quality. less and it's ugly, more and you're throwing away file space that could be used to actually encode at a larger dimension etc....

personally i noramlly only encode 1pass, and it's fine for me.

gonniff 09-15-2003 11:01 AM



I don't really follow what you mean about the pixel values(honestly, I know nothing about this technology). Can you give me a bigger hint plus a site where I might can learn more? Do I need an extra bit of software to figure out these pixel values?

Or could you give me an example based on one of the lines of script I'm running currently (that is, does it matter where in the string of commands I place any of your suggested options?).

I apologize if it sounds like I'm lazy. I'd just like to rule out any user errors due to me being new at this (and copy the two disks before my friend starts to miss them too much).

Would this be right for a possible cleaner option?

mencoder -dvd 1 -ovc lavc -lavcopts vcodec=mpeg4:vpass=1 -oac copy vhq:vqmin=2 scale=640:480 -o my_movie.avi

Thanks for your help.

acid_kewpie 09-15-2003 11:12 AM

this is a little script one of the mencoder guys wrote.... there is an indepth discussion of bpp in the mplayer mailing list if you search for "" in google....


#!/usr/bin/perl -w

use POSIX;

sub round {
  my $v = shift;
  return floor($v + 0.5) != floor($v) ?
    floor($v + 0.5) :

if (scalar(@ARGV) < 4) {
  print("Please provide a) the cropped but unscaled resolution (e.g. " .
        "716x524), b) the aspect ratio (either 4/3 or 16/9 for most DVDs), " .
        "c) the video bitrate in kbps (e.g. 800) and d) the movie's fps.\n");

($unscaled_width, $unscaled_height) = split('x', $ARGV[0]);.$encoded_at = $ARGV[1];.if ($encoded_at =~ /\//) {.  my @a = split(/\//, $encoded_at);.  $encoded_at = $a[0] / $a[1];.}.$scaled_width = $unscaled_width * ($encoded_at / (5/4));.$scaled_height = $unscaled_height;.$picture_ar = $scaled_width / $scaled_height;.($bps, $fps) = @ARGV[2, 3];..printf("Prescaled picture: %dx%d, AR %.2f\n", $scaled_width, $scaled_height,.      $picture_ar);.for ($width = 720; $width >= 320; $width -= 16) {.  $height = 16 * round($width / $picture_ar / 16);.  $diff = round($width / $picture_ar - $height);.  $new_ar = $width / $height;.  $picture_ar_error = abs(100 - $picture_ar / $new_ar * 100);.  printf("${width}x${height}, diff % 3d, new AR %.2f, AR error %.2f%% " ..        "scale=%d:%d bpp: %.3f\n", $diff, $new_ar, $picture_ar_error, $width,.        $height, ($bps * 1000) / ($width * $height * $fps));.}.

basically though it's the bitrate divided by the total area times the number of frames per second. i.e. the number of bits that each single pixel is given to store the data.

acid_kewpie 09-15-2003 11:14 AM

mencoder dvd://1 -ovc lavc -lavcopts vcodec=mpeg4:vpass=1 vhq:vqmin=2 -vop scale=640:480 -o my_movie.avi -oac mp3lame -lameopts abr:br=128

just noticed you're using audio copy... hell no wonder the fiels were so big!

gonniff 09-15-2003 11:21 AM


Thanks for all that. The Perl stuff goes a bit over my head, but I'll find that google posting you mentioned and read up on it.

Thanks, too, for the script. I'll take that home now (just going home) and run it on that DVD.

I'd really like to learn more about this. Had no idea that the copy option for the sound was the problem - just followed the guidelines in the docs. Should have guessed, though. Makes sense on reflection (but then, most things do, I suppose).

I'll let you know how the general quality pans out.

Really appreciate your time.


gonniff 09-16-2003 04:06 AM


I took your suggested values home and had a go.

The first run failed (seems my mencoder doesn't like the "://" redering. I also found I had to put the values in a different order to get it to accept them (said I hadn't selected any -oac values when I first tried the given format).

Anyway, it ran and the quality was pretty good, but it still has some blocky output. I'll try a second pass rendering tonight.

I also just printed out an article I found when searching for the perl script you printed above:

Again, the first string of entries listed failed:

mencoder dvd://1 -o /dev/null -oac copy -ovc lavc \
-lavcopts vcodec=mpeg4:vbitrate=1000:vhq:vqmin=2:\
vlelim=-4:vcelim=9:lumi_mask=0.05:dark_mask=0.01:vpass=1 \
-vf crop=716:572:2:2,scale=640:480

To me, not surprising as it was directed to /dev/null to start with. Hmmm.....

I removed this and moved the -oac settings around and it ran, but still produces one big block in the center of the screen rather than the nice "letterbox" format. I'll keep reading and keep experimenting.

And I haven't forgotten about your acidrip! I need to install the other components first and then I'll give it a go.

Are there any pointers or things I should be mindful of since you first put this out that might make using it more successful?

Thanks in advance for your help.


acid_kewpie 09-16-2003 05:34 AM

well the biggest thing there is still that you are straight copying the audio, so are including a 400kbps stream rather than a more suitable 128kbps in mp3 format.

/dev/null is being used as that is the first pass, and so you only really want the divx2pass.log file, not the actual video.

gonniff 09-16-2003 06:40 AM

Thanks. Any ideas why the script failed with /dev/null included? Only ran once I took that out.

Also, I just used it as is the first time, but put in your suggested mp3lame settings on the second go. Output wasn't that bad.

You mentioned that this would produce a log file (I'm assuming like with the 2 pass method I've used up to now). Will this de facto increase the quality or have I misunderstood? You mentioned you use single pass encoding with good results.

One last point that struck me when trying to encode "Crouching Tiger" last night: I did a test run of about 45 seconds and found when I played it back it had the commentary as default and not the Mandarin or English soundtrack. How weird is that?

All times are GMT -5. The time now is 03:56 AM.