Wednesday, January 17, 2007

Modify ASF/WMV Pixel Aspect Ratio Using WMV Aspect Ratio Changer by DVBPortal

This article helps you understand what SAR, PAR, and DAR are, and how to use them to correct Windows Media Video (WMV) aspect ratio flaws without the need to transcode / re-encode such files in Microsoft’s Advanced Systems Format (ASF).

There are cases where ASF WMV files are encoded in wrong dimensions. This is the reason behind why some videos look squeezed or stretched horizontally when viewed on a normal media player—without DAR correction. In other words, the width/height of the sampled Windows Media Video is not right, or as digital media geeks say, “the storage aspect ratio (SAR) is not right.”

The storage aspect ratio—also called sample aspect ratio—or SAR in short, is simply the ratio of horizontal pixels to vertical pixels, inside the sampled video. For example, the NTSC DVD Video VOB files (720x480) always have a SAR of 1.5 (3:2), regardless of whether they’re encoded for a normal (4:3 / 1.33) or a widescreen (16:9 / 1.78) television.

The pixel aspect ratio (PAR) of a frame is the shape of an individual pixel. For playback purposes it’s important to know the video’s display aspect ratio (DAR), but it’s only if the pixel aspect ratio (PAR) is stored in the video, so it can be used to determine the correct display aspect ratio. Likewise, if no PAR information is stored, it can be calculated from the video’s DAR. For example, the NTSC Video VOB files (720x480) have a PAR of either 1.185 (32:27) or 0.889 (8:9), depending on whether they’re encoded for a normal (4:3 / 1.33) or a widescreen (16:9 / 1.78) television respectively.

The display aspect ratio (DAR)—also called picture aspect ratio—is the actual shape a frame is supposed to be displayed with, rather than simply the resolution. For example, the NTSC and PAL DVD-Video VOB files always have a DAR of either 1.33 or 1.78, depending on whether they’re encoded for a normal (4:3 / 1.33) or a widescreen (16:9 / 1.78) television respectively.

Equations

Storage Aspect Ratio = Horizontally Stored Pixels ÷ Vertically Stored Pixels
or
Storage Aspect Ratio = Width ÷ Height
or simply
SAR = W ÷ H

Display Aspect Ratio = Storage Aspect Ratio × Pixel Aspect Ratio
or simply
DAR = SAR × PAR

To calculate pixel aspect ratio, when we want to force a video with a fixed SAR (this cannot be changed, because it’s actually video’s own width to height ratio) to be displayed with a specific DAR—commonly normal (4:3) or widescreen (16:9):

PAR = DAR ÷ SAR

Modify ASF/WMV Pixel Aspect Ratio Using WMV Aspect Ratio Changer by DVBPortal

The ASF container—like many other containers—has the ability to store a pixel aspect ratio (PAR), to correct the ratio of what’s eventually rendered as a video on the screen. The pixel aspect ratio is set by writing the AspectRatioX and AspectRatioY properties in ASF’s metadata header.

Example

For example, there’s this WMV file, with 720x480 dimensions. From what I’ve described earlier, it has a storage aspect ratio (SAR) of 1.50 (3:2)—right out of the dimensions:

SAR = W ÷ H
SAR = 720 ÷ 480 = 1.50 (3:2)

Trying to watch the video, if I noticed it’s stretched horizontally, I need to correct the display aspect ratio (DAR) to normal 4:3.

DAR: 1.33 (4:3), because video looked horizontally stretched
SAR = W ÷ H
SAR = 720 ÷ 480 = 1.50 (3:2)
PAR = DAR ÷ SAR
PAR = 1.33 ÷ 1.50 = 0.889 (8:9)

So, for this correction, I need a 0.88 (8:9) pixel aspect ratio (PAR).

But if the video looked squeezed horizontally, I need to correct the display aspect ratio (DAR) to widescreen 16:9.

DAR: 1.78 (16:9), because video looked horizontally squeezed
SAR = W ÷ H
SAR = 720 ÷ 480 = 1.50 (3:2)
PAR = DAR ÷ SAR
PAR = 1.78 ÷ 1.50 = 1.185 (32:27)

So, for this correction, I need a 1.18 (32:27) pixel aspect ratio (PAR).

Now to apply the calculated pixel aspect ratio (PAR) to the ASF/WMV, use WMV Aspect Ratio Changer by Crypto at DVBPortal. Run WMVARChanger.exe and “Load” the .WMV file you want to modify. “Current Aspect Ratio” displays your video’s current aspect ratio, if set. Otherwise, “<none>” is shown. Inside “New Aspect Ratio”, enter “Aspect Ratio X” and “Aspect Ratio Y”, for horizontal and vertical aspect ratios, respectively. (e.g., 32 and 27 for a PAR of 1.185) Now click “Apply” to fix and overwrite the existing file.

Please note you can use the same tool just to remove a WMV’s current aspect ratio, if set. To do so, “Load” the .WMV file, and click “Remove” to patch and overwrite the existing file.

Also please note because WMV Aspect Ratio Changer tends to overwrite its loaded file, I recommend making a clone copy of your WMV/ASF file, and then try to patch the duplicated file using WMVARChanger.exe.

Another Example

There’s an NTSC WMV file, with 704x480 pixels inside, resulting a storage aspect ratio (SAR) of 1.467:1 (22:15).

Consider this clip is a wide (16:9) motion picture—meaning a picture aspect ratio (DAR) of 1.778:1.

Now to make it right, we’d need a pixel aspect ratio (PAR) of 1.212:1 (40:33).

If the same video is a normal (4:3) clip, then we should apply a PAR of 0.909 (10:11).

A PAL Example

There’s this PAL WMV file, encoded containing 704x576 pixels along. This results a sample aspect ratio (SAR) of 1.222 (11:9).

Now if this is a wide (16:9) HDTV clip, then a pixel aspect ratio (PAR) of 1.455:1 (16:11) is needed to display the movie right.

But if the same video is suited to normal (4:3) SDTV screens, then a PAR of 1.091:1 (12:11) is needed.







Copyright © 1999-2012 Komeil Bahmanpour. All rights reserved.


Reproduction is permitted provided that the source is acknowledged and a link is included to the relevant article.