PDA

View Full Version : Set DAR in Xvid codec setting that has a problem?


VoidShell
8th August 2007, 18:18
I use avi container and AviSynth.
I resize video(d2v) to original aspect ratio(1.85 or 2.35) but I can't resize exactly to original aspect ratio for keeping 8x.
I use width 720 or 800 then generated asect ratio has a nearly 1.87 or 2.38.

So I try DAR in Xvid codec setting but I hear that it has a problem. Because DAR information is saved in bitstream, and then it has a decoding problem.

Q1. Is it true? DAR in Xvid codec setting is not recommended?

Q2. Can't I do DAR setting in AviSynth?

SeeMoreDigital
8th August 2007, 18:38
Q1. Is it true? DAR in Xvid codec setting is not recommended?No, it's rubbish.

I generate Xvid encodes complete with aspect ratio signalling (DAR, PAR, SAR... call it what you will) embedded within the MPEG-4 video stream all the time. Playback of such files works just great in hardware and software players ;)

Q2. Can't I do DAR setting in AviSynth?Can't answer that one!

Brother John
8th August 2007, 18:56
I resize video(d2v) to original aspect ratio(1.85 or 2.35)
Those well known standard numbers are hardly ever an exact representation of the original DVD AR because
1) The actual active DVD frame is not at all fixed to those numbers. The original film might have been off. Then there's the whole DVD production process that may introduce deviations.
2) The cropping you do usually cuts of at least one or two active pixel lines, which changes the DAR.
Don't get me wrong. Sticking to the standard DAR ratios is not bad per se. But it fails as a strategy for keeping the original AR (how ever you want to define that) as closely as possible. For example a lot of modern 2.35 movies actually have a frame size more like 2.40 even on the original film.

Q2. Can't I do DAR setting in AviSynth?
No, has to be done on the encoder side. AviSynth doesn't know about pixel shapes at all.

VoidShell
10th August 2007, 11:14
SeeMoreDigital//Thanks so much.

Brother John//OK, I understand your massage. But is it true? Original DVD AR is not a original?

For example a lot of modern 2.35 movies actually have a frame size more like 2.40 even on the original film.

But in my country, 2.35 movie source that comes to DVD has a correct aspect ratio I think. I make 2.35 to 2.40 then character's face is pressed. I compare still image cut captured by 35mm movie camera with those 2.40 image made by me, that there is a quite difference about those two image. 2.40 image made by me seems to pressed so is not a normal character's face as to my eyes.

SealTooGreat
10th August 2007, 11:24
@VoidShell

Just crop(not resize - it's important) your anamorphic DVD's source and if it's PAL use PAR=64:45 and if it's NTSC use PAR=32:27

That's all ;)

Brother John
10th August 2007, 13:12
It's not a matter of country. Some movies are originally shot with an AR of rather ~2.40 than 2.35 in mind. I think the newer Star Wars movies are one example. If you force such a movie to 2.35 AR is obviously off. But if you feel more comfortable watching it this way, do it.

However, always be very very careful with DAR settings because there's much more that 1.33, 1.78, 1.85 and 2.35. "James Bond Dr. No" for example has a (on the film negative) 1.60 ratio, "Lawrence of Arabia" is 2.20.

If you have the disc space and no standalone restrictions, SeelTooGreat's method is the safest way. It won't give you those nice and "perfect" even AR numbers though, but will be close. His numbers are the 16:9 generic PARs. If you have a 4:3 disc use 16/15 (PAL) and 8/9 (NTSC). Those are PARs, not DARs! That's important to remember when setting up Xvid.

SealTooGreat
10th August 2007, 15:02
It's not a matter of country. Some movies are originally shot with an AR of rather ~2.40 than 2.35 in mind. I think the newer Star Wars movies are one example. If you force such a movie to 2.35 AR is obviously off. But if you feel more comfortable watching it this way, do it.

However, always be very very careful with DAR settings because there's much more that 1.33, 1.78, 1.85 and 2.35. "James Bond Dr. No" for example has a (on the film negative) 1.60 ratio, "Lawrence of Arabia" is 2.20.

If you have the disc space and no standalone restrictions, SeelTooGreat's method is the safest way. It won't give you those nice and "perfect" even AR numbers though, but will be close. His numbers are the 16:9 generic PARs. If you have a 4:3 disc use 16/15 (PAL) and 8/9 (NTSC). Those are PARs, not DARs! That's important to remember when setting up Xvid.

If VoidShell want square pixel encode like 720x???, 704x???, 640x???, 624x??? etc He can calculate exact DAR upon formula:

DAR = source's PAR * cropped_width / cropped_height

... where source PAR is, in fact, generic one.

Process of calculating accurate DAR is:

1. Crop (not resize) you DVD's source (let say it's PAL 720x576, DAR=16/9) and take a note of new cropped resolution. (let say that new one is 704x432)

2. Now we have values:

PAR = 64:45 (because it's PAL, DAR=16/9)
cropped_width = 704
cropped_height = 432

3. put those parameters in above equation and you will get

DAR = 2.3176954

4. Choose width (mod 16). Let say width = 624. Than you will get height from equation:

DAR=width/height -> height=269.23296 -> round the number to obey mod 16 -> so finally height=272

5. Resize your cropped source to resolution 624x272 (you will get some AR error cause of rounding the height's number)

6. set PAR=1:1 in XviD encoder and encode the movie.
============================================
So, VoidShell, I really don't know what is your attention:

1.to encode movie like squeezed (only crop to remove black borders) and set appropriate DAR/PAR signalization flag?

or

2. to encode square pixel (aka PAR=1:1)?

In 1st case I would use suggested generic PARs (not DARs, cause generic PARs are constant), and in the 2nd, above mentioned DAR calculation. 1st way is accurate (my favorite), 2nd probably, in most cases, need rounding res. to satisfy mod 16.

VoidShell
11th August 2007, 06:58
To Brother John. OK, I understand your massage.
From now on I calculate aspect ratio with my own hand. Thanks so much.

Thanks SealTooGreat. I appreciate your help.
I try it as your advice.

1. My source is NTSC 720 x 480, DAR=16/9

2. PAR = 32:27
cropped_width = 714
cropped_height = 360

3. (32/27)*(714/360)=DAR
DAR = 2.350617

4. my choosen width 720.
720 / 2.350617 = 306.302558
round the number to obey mod 16 -> so finally height -> 304

5. resize 720 x 304 in AviSynth.

6. I set PAR=1:1 in XviD encoder and encode the movie.

OK, wonderful. But As my question was written, 720 x 304 is not a correct
aspect ratio because I round the number to obey mod 16.
Look at this, 720 / 304=2.368421

So I set to DAR for correct aspect ratio than PAR=1:1 in step 6.
720 x 304(Resizing in AviSynth) is left in SAR.

http://img396.imageshack.us/img396/2649/d9avisynthresizesarrr7.jpg


And then set DAR to 2.35:1(Setting in Xvid)

http://img396.imageshack.us/img396/2240/d9xvidsetdarle9.jpg


I encode like this and play in KMPlayer (http://www.kmplayer.com/forums/index.php) used many people in my country.
In KMPlayer, there are selecting options about display method to DAR, SAR.

http://img518.imageshack.us/img518/2589/d9kmplayerdarbe7.jpg



As select "Keep Storage Aspect Ratio(SAR)", video is displayed to 720 x 304 (2.368421)

http://img217.imageshack.us/img217/5585/d9lovelettersarjy3.jpg



As select "Keep Display Aspect Ratio(DAR)", video is displayed to 715 x 304 (2.351974)

http://img217.imageshack.us/img217/1174/d9loveletterdargv2.jpg



It is my purpose that SAR is some closed to original aspect ratio but not a more close because round the number to obey mod 16, so I set to additional DAR for more closing original aspect ratio while keeping mod 16 in SAR.

Anyway I do encode like this the best way I think.
Do you agree to my opinion?


1.to encode movie like squeezed (only crop to remove black borders) and set appropriate DAR/PAR signalization flag?

or

2. to encode square pixel (aka PAR=1:1)?

In 1st case I would use suggested generic PARs (not DARs, cause generic PARs are constant), and in the 2nd, above mentioned DAR calculation. 1st way is accurate (my favorite), 2nd probably, in most cases, need rounding res. to satisfy mod 16.

I don't understand this massage. As you know, I'm not good at english. Sorry.
I wrote my process so you may understand my encoding process. :)

In addional, I find Aspect (http://aspect.fre3.com/downloads/aspect_2.1.0.zip), it calculate a original apsect ratio to auto process. It is very easy :)

http://img518.imageshack.us/img518/5109/d9aspectaw5.jpg

Brother John
11th August 2007, 14:58
Your objective is an encoding with an AR as close to the "original source AR" as possible, right? Then you should keep two things in mind:

– Forget those nice and even AR numbers (1.33, 1.78 etc.). They're meaningless.
– There's so many places for small errors and deviations that reaching the "perfect source AR" is virtually impossible. Getting close is all you can do.

Easiest, traditional way of encoding:
Pick the encoding frontend you like (StaxRip, MeGUI, Gordian Knot etc.), crop and resize to a square pixel resolution (that's done more or less automatically). Don't worry about the AR error. You'll hardly ever be in danger of noticing it anyway.

"Modern", but slightly more tricky method:
Crop, do NOT resize. In Xvid choose the appropriate source "Pixel AR" from the combobox. AR error will generally be lower, but this methods needs rather large file sizes: I'd go for 2240 MB (1/2 DVD) per movie. Also, hardware players might have problems with such a file.

For both methods, mod16 is not exactly mandatory. However, non-mod16 resolution means lower encoding efficiency, i.e. lower quality for the same file size. The definitive restrictions are mod4 horizontally and mod2 vertically.

And if you really want to get disillusioned about the "perfect AR": read up on the whole generic vs ITU-R BT.601 PAR issue. ;)

Brother John
11th August 2007, 17:03
I feel so confused why aspect ratio diffrent "GKnot" and formula written by SealTooGreat (or "Aspect")
That's the generic vs. ITU PAR thingy. You can set whichever calc method you prefer on GK's "Options" tab.

VoidShell
11th August 2007, 17:28
Thanks, Brother John.
First step, I try it with GKnot.

http://img519.imageshack.us/img519/7867/d9gkontpreviwebd2.jpg

http://img519.imageshack.us/img519/7929/d9gkontsettingfm0.jpg

http://img480.imageshack.us/img480/6783/d9gkontsetting2hu0.jpg

http://img519.imageshack.us/img519/333/d9gkontavslx7.jpg

I feel so confused why aspect ratio diffrent "GKnot" and formula written by SealTooGreat(2.350) or util named to Aspect(2.350).

GKnot calculates aspect ratio to 2.410.
Formula written by SealTooGreat (or "Aspect") caluates aspect ratio to 2.350.

Why these are diffrent? Is calculating formula diffrent?
Which one is true?

It is so confused to me.


Two step, it is good for more precise aspect ratio but as you say

but this methods needs rather large file sizes: I'd go for 2240 MB (1/2 DVD) per movie. Also, hardware players might have problems with such a file.

So I don't want this method.



In my country, width 720 or 800 is standard to DVD movie ripping.

So I can't use like this

http://img480.imageshack.us/img480/6783/d9gkontsetting2hu0.jpg

Keeping width 720 or 800 and mod 16, it is imposible that SAR is closed to original aspect ratio.
It counts for nothing that true is GKnot calculating formula(2.410) or Formula written by SealTooGreat(2.350) or util named to Aspect(2.350).
Under my condition in keeping width 720 or 800 and mod 16 if i don't set DAR, aspect ratio couldn't been macthed like 720 x 304 (2.368421) or 800 x 336 (2.380952) to (2.410) or (2.350) both.
It is imposible, so I have to set DAR. Is it wrong?

VoidShell
11th August 2007, 17:51
That's the generic vs. ITU PAR thingy. You can set whichever calc method you prefer on GK's "Options" tab.

Thanks. I will read generic vs ITU-R BT.601 PAR issue.

SealTooGreat
11th August 2007, 22:17
VoidShell, there's nothing wrong about the way you have encode your movie (720x304), though the accurate res. is 720x306. This is acceptable AR error. Most people will stay with that resolution and use PAR=1:1 signalization for displaying at DAR=720/304=2.36842=2.37, though the appropriate one is DAR=720/306=2.3529=2.35, but accurate (from equation) is DAR=2.350617=2.35.

If you are not that sort of people who is satisfied with that acceptable AR error you can set DAR=2.350617=2.35(from equation) in XviD encoder for current resized resolution 720x304(which have DAR=2.36842=2.37 if you encode like square pixel PAR=1:1). So, by the same spoken it's also the right way, getting accurate DAR displaying upon playback, as you have shown by screenshots of that sweet girl. On the 1st one you have 720x304 , and on the 2nd one 715x304 (which satisfies the DAR=2,35 from from equation ). And that is why AR signalization is used for to correct AR upon playback.

Personally, I prefer to do crop (not resize) and in Xvid cofiguration box to set appropriate source "Pixel AR".

So that means (in your case) if you crop source DVD you will get 714x360 (width is even smaller than 720 or 800 as standard for the DVDrip in your country;)). Encode like 716x360 (try to satisfy (only by cropping) if not mod 16 than mod4 horizontally and mod2 vertically like 716x360) with PAR=32:37 typed in XviD encoder.

So instead of 720x304 you are now dealing with 716x360. Higher resolution means you have to apply more bitrate to encode. That's why Brother have said this methods needs rather large file sizes: I'd go for 2240 MB (1/2 DVD) per movie . Some would go for 1.3gb (1/3 DVD), but under that I'd not recommend.

VoidShell
13th August 2007, 12:21
Brother John//

I read this thread which contained conflicting your and unskinnyboy's claims.
http://forum.doom9.org/showthread.php?t=114143&highlight=ITU-R+BT.601+PAR

unskinnyboy: There is no definite way to know for sure, although from experience, pillarboxing of ~8 pixels on both sides indicates the presence of ITU-R (usually). 99% of the recent Hollywood movies come without ITU-R resizing, but the same can't be said for other DVDs from other regions.

Brother John: What makes you so sure? If it's just because of missing vertical bars, that's a weak argument. I could think of a number of ways for ITU without bars."

unskinnyboy: No, it's not because of the lack of pillarboxing of the kind I mentioned few posts above (even that doesn't conclusively indicate lack of ITU-R, as I myself had noted)

So now, I don't think that all of the movie need ITU-R resizing, and movie used ITU-R resizing decrease day by day. Nevertheless, ITU-R resizing is as mainly as ever in old movie. But it is not a same word all of the old movie use ITU-R resizing.

So, anyone must not be convinced of whether movie use ITU-R resizing before sphere testing like your saying.

I really appreciate your attention and reply. But you this the above it does not sphere test to my source, you wouldn't like to convince whether movie use ITU-R resizing. It is put me to inconvenien. But It is just a little. I appreciate to know ITU-R resizing introduced by you.

VoidShell
15th August 2007, 16:40
SealTooGreat //

Thanks very much. I really appreciate your help. In conclusion, your massage saids there's a no problem that I use DAR leaving a SAR.

But I decide that I don't use DAR because of ITU-R resizing, I don't enough to have a time for sphere testing on source whether ITU Resizing or not.

So I decide use 720 x 304 that has a DAR 2.37 which is a average 2.35 and 2.40. So I decide to use 720 x 304 and PAR 1:1. :)

It thanks again in once you help.

SeeMoreDigital
16th August 2007, 13:04
Unlike the pre-defined PAR values attributed to MPEG-2 DVD video streams (DAR 4:3 and DAR 16:9), MPEG-4 video streams can be assigned any PAR value you wish. And therefor any pixel shape you wish.

Essentially this means that despite being limited to generating MPEG-4 encodes using mod-16 pixel blocks, it's possible to generate "cropped and resized" MPEG-4 encodes matching the exact aspect ratio of the original MPEG-2 DVD movie source..... And this is how you do it: -



Step 01:00 - Finding out the exact aspect ratio of your original MPEG-2 DVD movie source - This is known as the MAR or "Movie Aspect Ratio".

Step 01:01 - Play a section of your MPEG-2 DVD in VLC player (as an example I'm using the PAL DVD version of Lawrence of Arabia). Find a nice well light bit of the movie. Press the "Pause" key. Click on the "Video" tap and scroll down and click on "Snapshot".

Step 01:02 - Find the "Snapshot" image. And open with some image editing software (Personally I use HyperSnap-DX 5. But each to their own).

http://img505.imageshack.us/img505/742/00source1024x576qg9.jpg

Step 01:03 - Use the image editing software's auto-crop function to trim the black mattes away. And then save the image.

http://img514.imageshack.us/img514/4193/021000x462croppedmarof2uk4.jpg

Step 01:04 - Find the "saved image" and "right click" over it and click on "Properties". Click on the "Summary" tab (the "Advanced" button) and make a note of the images "Width" and "Height" aka: PFS or "Pixel Frame Size".

http://img514.imageshack.us/img514/5732/resolutionuy6.png

Step 01:05 - Grab a calculator. And divide the "Width" of the image by its "Height". The resulting calculation will reveal the exact MAR (Movie Aspect Ratio). In the above case: an PFS of 1000 ÷ 462 = an MAR of 2.1645021:1



Step 02:00 - Working out your nearest MPEG-4 mod-16 PFS (pixel frame size).

Step 02:01 - The pixel width of your encode is straight forward, it's 720 pixels (the same as any commercial DVD). The pixel height will be the closest mod-16 pixel value to your "saved image". In this case: The nearest mod-16 pixel value to 462 is 464.

Okay, we now have a "cropped and resized" PFS for our proposed anamorphic MPEG-4 encode, it's 720x464 pixels. But how do we work out the correct level of ARS (aspect ratio signalling) aka: PAR to add to our MPEG-4 stream?



Step 03:00 - Working out the correct level of ARS (aspect ratio signalling) aka: PAR.

Step 03:01 - Download an application I conceived (thanks to Moitah) called the "ARS Calclator" (http://www.one.seemoredigital.net/Downloads/ARS_Calculator.zip). It looks like this: -

http://img168.imageshack.us/img168/8204/arscalchz2.png

Step 03:02 - In the "Pixel Frame Size" section enter "720" and "464" (within the boxes provided). In the "Movie Aspect Ratio" section, click on the "Custom" (radio) button and enter "2.1645021" and "1" (within the boxes provided). Now press the "Calculate" button. In the box directly below you will now see your required "Aspect Ratio Signalling" value. It will look like this: -

http://img404.imageshack.us/img404/8588/arscalcvaluexb3.png



Step 04:00 - How do I enter the ARS value into my MPEG-4 encoding application?

Step 04:01 - This will depend on your encoding application. However, it's also possible to add/alter the ARS value of any MPEG-4 Part-2 or Part-10 stream using tools such as MPEG4 Modifier and MP4Box respectively.



Step 05:00 - How do I know it's worked?

Step 05:01 - Play a section of your MPEG-4 encode in VLC player. Find a nice well light bit of the movie. Press the "Pause" key. Click on the "Video" tap and scroll down and click on "Snapshot".

http://img89.imageshack.us/img89/2628/mpeg4encodezo1.jpg

Step 05:02 - Find the "Snapshot" image and "right click" over it and click on "Properties". Click on the "Summary" tab (the "Advanced" button) and make a note of the images PFS.

http://img508.imageshack.us/img508/8440/mpeg4encoderesmj3.png

Step 05:03 - Grab a calculator. And divide the "Width" of the image by its "Height". The resulting calculation should be very close to the MAR found in "Step 01:05" (ie: 2.1645021:1). In this case: a PFS of 1004 ÷ 464 = an MAR of 2.163793:1..... And that's about as close as it gets!



Step 06:00 - Enjoy your new anamorphic 720x??? MPEG-4 cropped and re-sized encode in your software or hardware player


Cheers