Log in

View Full Version : Need some help 4 XViD settings


Smoke85
14th May 2004, 18:06
Hi all,

I'm trying to encode a 4:3 movie with the latest XViD codec (1.0 RC4)
at 640 x 480 resolution.

Picture quality is great, except when there's a closeup of someone's face, there are a lot of blocks around the (fast moving) mouth. It looks like the whole picture is encoded at high bitrate, and only the mouth at very low bitrate. Lowering resolution doesn't seem to make much difference.

I use lastest Gordian Knot, movie duration is 42 minutes and should fit in 350MB.

I guess this has something to do with my XViD settings, can anyone tell me which settings I need to adjust ? I read all guides I could find, but since I don't fully understand how XViD works internally, they aren't any help for me... :-/

Thankx a lot !

Smoke85

obieobieobie
14th May 2004, 18:10
You should post your initial settings.

Also, you may need to lower your resolution.

Smoke85
14th May 2004, 18:45
I already tried to lower resolutions, that didn't help... :(

Changing quantization type to MPEG seems to help a little, so I guess it has something to do with that ??

Here are my settings:

"mode"=dword:00000001
"quality"=dword:0000005a
"quant"=dword:00000005
"rc_bitrate"=dword:000dbba0
"rc_reaction_delay_factor"=dword:00000010
"rc_averaging_period"=dword:00000064
"rc_buffer"=dword:00000064
"motion_search"=dword:00000006
"quant_type"=dword:00000000
"fourcc_used"=dword:00000000
"max_key_interval"=dword:0000012c
"min_key_interval"=dword:00000001
"lum_masking"=dword:00000001
"interlacing"=dword:00000000
"greyscale"=dword:00000000
"min_iquant"=dword:00000001
"max_iquant"=dword:0000001f
"min_pquant"=dword:00000001
"max_pquant"=dword:0000001f
"desired_size"=dword:0000313e
"keyframe_boost"=dword:00000014
"discard1pass"=dword:00000001
"dummy2pass"=dword:00000000
"kftreshold"=dword:0000000a
"kfreduction"=dword:0000001e
"curve_compression_high"=dword:00000019
"curve_compression_low"=dword:0000000a
"use_alt_curve"=dword:00000000
"alt_curve_use_auto"=dword:00000001
"alt_curve_auto_str"=dword:00000032
"alt_curve_use_auto_bonus_bias"=dword:00000001
"alt_curve_bonus_bias"=dword:00000032
"alt_curve_type"=dword:00000001
"alt_curve_high_dist"=dword:0000012c
"alt_curve_low_dist"=dword:0000012c
"alt_curve_min_rel_qual"=dword:00000032
"bitrate_payback_delay"=dword:000000f0
"bitrate_payback_method"=dword:00000000
"twopass_max_bitrate"=dword:00989680
"twopass_max_overflow_improvement"=dword:0000003c
"twopass_max_overflow_degradation"=dword:0000003c
"hinted_me"=dword:00000000
"credits_start"=dword:00000000
"credits_start_begin"=dword:00000000
"credits_start_end"=dword:00000000
"credits_end"=dword:00000000
"credits_end_begin"=dword:00000000
"credits_end_end"=dword:00000000
"credits_greyscale"=dword:00000000
"credits_mode"=dword:00000000
"credits_rate"=dword:00000014
"credits_quant_i"=dword:00000014
"credits_quant_p"=dword:00000014
"credits_start_size"=dword:00002710
"credits_end_size"=dword:00002710
"hintfile"="\\hintfile.mvh"
"stats1"="\\video.stats"
"stats2"="\\videogk.stats"
"qmatrix_intra"=hex:08,11,12,13,15,17,19,1b,11,12,13,15,17,19,1b,1c,14,15,16,\
17,18,1a,1c,1e,15,16,17,18,1a,1c,1e,20,16,17,18,1a,1c,1e,20,23,17,18,1a,1c,\
1e,20,23,26,19,1a,1c,1e,20,23,26,29,1b,1c,1e,20,23,26,00,00
"qmatrix_inter"=hex:10,11,12,13,14,15,16,17,11,12,13,14,15,16,17,18,12,13,14,\
15,16,17,18,19,13,14,15,16,17,18,1a,1b,14,15,16,17,19,1a,1b,1c,15,16,17,18,\
1a,1b,1c,1e,16,17,18,1a,1b,1c,1e,1f,17,18,19,1b,1c,1e,00,00
"Brightness"=dword:0000001a
"Deblock_H_Y"=dword:01010101
"Deblock_V_Y"=dword:01010101
"Deblock_H_C"=dword:01010101
"Deblock_V_C"=dword:00010101
"Dering_Y"=dword:00000101
"Dering_C"=dword:14000001
"Horiz_Threshold"=dword:00000014
"Vert_Threshold"=dword:00000028
"chromame"=dword:00000001
"bitrate"=dword:000002bc
"use_2pass_bitrate"=dword:00000000
"desired_quant"=dword:00000190
"qpel"=dword:00000001
"gmc"=dword:00000000
"reduced_resolution"=dword:00000000
"use_bvop"=dword:00000001
"max_bframes"=dword:00000002
"bquant_ratio"=dword:00000096
"bquant_offset"=dword:00000064
"packed"=dword:00000000
"closed_gov"=dword:00000001
"ar_mode"=dword:00000000
"aspect_ratio"=dword:00000000
"par_x"=dword:00000001
"par_y"=dword:00000001
"ar_x"=dword:00000004
"ar_y"=dword:00000003
"num_zones"=dword:00000001
"full1pass"=dword:00000000
"kfthreshold"=dword:00000001
"overflow_control_strength"=dword:00000005
"container_type"=dword:00000001
"target_size"=dword:000a2800
"subtitle_size"=dword:00000000
"hours"=dword:00000001
"minutes"=dword:0000001e
"seconds"=dword:00000000
"fps"=dword:00000002
"audio_mode"=dword:00000000
"audio_type"=dword:00000000
"audio_rate"=dword:00000080
"audio_size"=dword:00000000
"vhq_mode"=dword:00000001
"cartoon_mode"=dword:00000000
"turbo"=dword:00000000
"frame_drop_ratio"=dword:00000000
"min_bquant"=dword:00000001
"max_bquant"=dword:0000001f
"trellis_quant"=dword:00000000
"debug"=dword:00000000
"vop_debug"=dword:00000000
"display_status"=dword:00000001
"Deblock_Y"=dword:00000000
"Deblock_UV"=dword:00000000
"Dering"=dword:00000000
"FilmEffect"=dword:00000000
"profile"="AS @ L5"
"stats"="E:\\Test Mond\\Test Mond_3.stats"
"zone0_frame"=dword:00000000
"zone0_mode"=dword:00000000
"zone0_weight"=dword:00000064
"zone0_quant"=dword:000001f4
"zone0_type"=dword:00000000
"zone0_greyscale"=dword:00000000
"zone0_chroma_opt"=dword:00000000
"zone0_bvop_threshold"=dword:00000000
"bquant_threshold"=dword:00000000
"dx50bvop"=dword:00000001
"use_trellis"=dword:00000000
"chroma_opt"=dword:00000000
"zone1_frame"=dword:0000fa77
"zone1_mode"=dword:00000001
"zone1_weight"=dword:00000064
"zone1_quant"=dword:000007d0
"zone1_type"=dword:00000000
"zone1_greyscale"=dword:00000000
"zone1_chroma_opt"=dword:00000001
"zone1_bvop_threshold"=dword:00000000
"credits_begin"=dword:00000000

obieobieobie
14th May 2004, 19:01
Yes, experiment with different quant matrixes.

Encode the portion of the source you've described in with the same settings save quant matrixes.

Smoke85
14th May 2004, 19:11
There are only 2 possibilities :confused:

obieobieobie
14th May 2004, 19:25
Err.. No. You have H263, MPEG and MPEG Custom where you can import from several custom matrixes.

Also, may I also recommend motion search presicion set at 6 ultra high and VHQ set to 4 wide search and chroma motion enabled.

Also consider enabling qpel and gmc.

Additionally, you might want to enable packed bitstream if you're going to use the AVI container. Vdub may display a bframe decoder lag, but there won't be any problems if you play the clip using directshow.

Teegedeck
14th May 2004, 19:25
Choose 'mpeg custom', then 'edit matrix', then 'load'. After that you can pick any custom matrix (coming in a zipped file with Koepi's version). Try a high-bitrate one (one with low numbers).

BTW, you've made sure that these blocks aren't there in the original already, haven't you?

Smoke85
14th May 2004, 20:57
Yes, the original is perfect without blocks...

Search precision is set on 6, chroma is always enabled and qpel on or off doesn't seem to make any difference for this issue.

I can't use packed bitstream cause I'm having problems playing it (very choppy play --> bug in ffdshow ?).

I'll try the mpeg custom options, since quant set to mpeg already gave me a better result.

Thankx for the tips, I'll let u know if it helps !

Smoke85
14th May 2004, 21:29
Now that's funny... A custom matrix for low bitrate gives better results than the ones for high bitrates or high quality !

In what way does this 'matrix' affect the quality of the movie ?

Sylf
14th May 2004, 21:38
I'm pretty uneducated about the matrices, but the basic idea is this: using these custom matrices and possibly AVS filters, what you want to do is to increase the compressibility of the whole film. When you pick those "low quality" matrices, it's formatting each frame(?) such that it can be compressed more. They do this by sacrificing some details, I believe. The real trick is to do this in the manner that's least noticible to the human eyes. With these tricks in place, when the not-so-important parts of the movies are compressed better than before, the encoder can spend more bytes, coding the fast motion section, like the people's mouth, in your case.


(hrm.... it's my best guess, so I might be making a fool of myself...)

sysKin
15th May 2004, 03:32
Important: press "load defaults" to delete all old and no longer used codec settings, such as the ones from alt_curve.

Smoke85
15th May 2004, 12:14
I just did SysKin, thankx !

By the way do you agree with Sylf's guess ? It's kinda strange: I always used the H263 quant for lower bitrate movies. This seems to work just fine for high-acties scenes, but gives macro-blocks around moving objects in almost static scenes. The MPEG quant (which I used for higher bitrates) doesn't seem to have this problem that much, as long as I don't choose a high quality custom matrix.

Does this have something to do with the fact that I used a 30sec low-action scene for testing ?

I don't understand: the Gordian Knot 5% comptest gives me a value around 0.112 Bits/(pixel*frame) for the whole movie (I stay around 0.200 usually) and my calculated bitrate is around 970...
:confused:

manono
15th May 2004, 14:13
Hi-

What don't you understand? Your resolution is obviously too high, or your filesize too low. If you insist on using that resolution, do it for a full CD and see what happens. I don't see that it's an XviD problem at all, but just a question of not enough bitrate.

By the way, forget that .112 and .200 stuff. What percentage did the compress test give you? It looks as if this film may be especially hard to compress.

You could try and run the .avi you already have through DRF Analyzer (http://www.geocities.com/analyzerDRF/). You might be surprised at the high quants you're getting.

Smoke85
16th May 2004, 19:27
Hi,

The compress test is what I meant with "comptest". :) It gave me a result of only 0.112 bits/pixel*frame, this indicates that the movie has a very high compression factor. This doesn't suprise me since it's a dark movie with few action scenes.

But I followed your advice and encoded the same movie with EXACTELY the same settings, but with 700MB as requested filesize.

1st of all, final filesize was almost 200MB too large (when going for 350MB it was exactely 350MB), and I don't see much difference between the large and the small versions. Some objects look shaper but I can't notice that unless I press my nose on the screen... :)

Switching quant from H263 to MPEG seems to avoid macro blocks around the mouths, i'm just trying to understand how ?

Blue_MiSfit
17th May 2004, 02:12
in short, the MPEG quantization matrix is designed to preserve more details than h263 or other "low bitrate" matricies.

However, this is a little strange because theoretically the MPEG matrix wants more bitrate, and would thus display more blocking than h263 at equal bitrates...

So what's happening in your case is exactly the opposite of what one would expect.

Wierd. Are you sure you didnt change any other codec settings, like your Bframe settings or the VHQ mode?

Smoke85
17th May 2004, 07:29
Yep I'm sure... ;)

Blue_MiSfit
17th May 2004, 08:14
how bizarre... I am at a loss with this one.
a most profitable anomaly.

-misfit

Koepi
17th May 2004, 08:35
blue_misfit:

Your interpretation of the mpeg quant matrix is a little wrong.

That matrix is extremely powerful. It's mighty.

Just do an encode with h263 quant and then again with mpeg quant.

If both encodes get the same bitrate at a 2pass encode, even though the mpeg quant matrix encode will use higher quantisers, the resulting quality will surpass the h263 quantised one in terms of blockyness by far. The blocks fit better when using mpeg quant.
If you compare it to any custom or h263 matrix, take a look how "oddly visible" blocks are if they occur.

That's why I mostly prefer mpeg quant matrix, in that term it is simply unbeatable (at least I didn't find a matrix which could quantize so high without getting blocky).

Regards
Koepi

Smoke85
17th May 2004, 20:53
It's good to know it wasn't me messing things up... ;)

But I'm happy, I managed to encode a 42min movie at 578 x 384 resolution with 350MB filesize at good quality with standard MPEG quant. As Koepi indicated, none of the custom matrixes gave me the same result !

Thankx for your help.

manono
18th May 2004, 07:29
It's good to know it wasn't me messing things up...

I wouldn't be too sure about that if I were you. Initially you did it at 640x480=1.33:1. Now you say you did the same video at 578x384. I'll assume that's a typo, and you really mean 576x384=1.50:1 (if NTSC). Either the first or the second has real bad AR, and I suspect the second. Setting the Input Pixel Aspect Ratio to 1:1 could do that, but there may be other ways as well.

Smoke85
18th May 2004, 17:35
Oh my god, I'm so stupid ! I DID mess up ! :eek:

No you're right, it was a typo. Final movie size is 576 x 416... :D