Pixel Aspect Ratios
Download the project files here.
There is a great deal of confusion about Pixel Aspect Ratio. Most of the time After Effects does a great job of mixing sources if you just leave things at the default settings. It's only when you break the rules that you start to get into trouble. You have to know the rules so that you know when you've broken them.
DV footage is almost always rectangular pixels. Computer generated images are almost always square pixels. Why is there a difference? Isn't it always best to work with square pixels?
There's a difference because engineers wanted to make higher resolution television images without changing the number of scan lines and, NO, it's not always best to work with square pixels.
After Effects always works with square pixels in the Composition window. This is why rectangular pixel images look a little distorted in the Composition window. Look is a key word here. They look distorted in the Composition window but they do not behave distorted and they do not appear distorted when displayed on a video monitor. Let's simplify and de mystify this process.
Open the PixelRatio.aep project included in the project files. There are six images created at standard video project sizes and six compositions created using default settings for six different video frame sizes. Figure 1 shows the project window for two compositions containing the 640_X_480.jpg. One composition is NTSC Square pixels at 720 X 540 pixels, the other is NTSC rectangular pixels @ 720 X 486 pixels.
Figure 1. Square and rectangular pixel compositions
The circle in the NTSC SQ composition on the left appears to be a perfect circle. The circle in the NTSC Rec composition on the right looks distorted. It looks distorted because After Effects has taken the square pixels in the original image and stretched them so that the image retains its original aspect ratio. The important thing to remember here is that the pixels in the image have changed in the NTSC Rec composition, but the image has not been distorted. It only looks distorted in the Composition window. The circle is still a circle and it will behave very nicely when rotated. So, are you confused yet? We must all stick together. Listen to Dr. Strangepixel. We must work quickly or there will be a mind shaft gap. (I know how old you are if you got that joke. For those that got it, I sincerely apologize.)
Notice the little pointer at the right edge of each circle. If the footage is rotated 90° (Figure 2) and the circle is still a circle, the pointer will remain at the edge of the circle.
Figure 2. The way things look when the pixel aspect ratios are correct
The circle on the right still appears to be distorted but the edge of the circle is exactly lined up with the pointer. It must be perfectly round, and it is. It only looks distorted in the Composition window.
In this case, the footage in both compositions is interpreted correctly.
Figure 3 shows the same compositions with the 720_X_480.jpg placed in the composition. Notice that the circle now appears to be a little taller than it is wide on the left and that it appears to be correct in the composition on the right. There is a clue here. The position of the pointers has not changed.
Figure 3. Now things look wrong on the left and right on the right.
Even though the footage in the NTSC Rec composition appears display a perfect circle, the footage is distorted. It only looks right in the composition window. If the footage is rotated 90° (Figure 4) the top of the circle will swing out and touch the pointer and both images appear to be distorted.
Figure 4. Both images are now distorted.
Why did this happen? What the heck is going on. The 640_X_480.jpg and the 720_X_480.jpg were both created in Photoshop. The circle in both images is exactly 480 pixels in diameter. So why did the smaller image work in both compositions and the larger image distort in both compositions. Click on the 720_X_480.jpg in the Project window and check the thumbnail and file info. (Figure 5) After Effects has incorrectly interpreted the pixel aspect ratio of the 720_X_480.jpg as "D1/DV NTSC" because 720 X 480 is a standard D1/DV NTSC image size and should have rectangular pixels. This happens every time you import an image with standard rectangular pixel dimensions. So there's the first rule that has been broken. The image was created at the wrong size.
We can fix the problem by changing interpretation. Open the Interpret footage window by selecting the footage you want to change in the Project window and then CMND/CTRL + F click. Change the Pixel Aspect Ratio to Square Pixels. Your compositions should now look like Figure 6. The tutorial project contains several examples that you can experiment with. There is also a folder that contains copies of the 3 JPEGs that have been reinterpreted to work properly in the comps. If you play around with these files for about 10 minutes you'll never have any question of what to do about Pixel Aspect Ratios.
Figure 6. Pixel Aspect ratio changed to Square Pixels and all is right with the world again.
Working With Non Square Compositions
Some artists prefer to create all of their projects as square pixel compositions for editing. After editing is complete a new composition is created at the appropriate size and their edited composition is placed in the new non-square comp for rendering. It is not necessary to do this. It may be more convenient for you, but it is not necessary. There is no technical reason to do so. AE5's pixel aspect correction option (Figure 7) will give you a proper preview if you decide to work directly in rectangular pixel compositions. You will be presented with a warning dialogue the first time you choose this option. Follow the advice. Pixel aspect correction is not a good option to select for editing your compositions, but it will provide a properly proportioned preview.
Figure 7. AE 5's Pixel Aspect Correction option.
Let's look at the standard techniques for working with non square compositions. The first option is to create all of your NTSC artwork and your composition at the larger 720 X 540 composition size. All DV footage at 720 X 486 is forced to fit in this new composition by using the Fit to Composition option. DV footage in the time line is selected and then CMND + OPTION + F is used to stretch the footage to fill the window. The 720 vertical pixels are preserved, but they are now taller. The 486 scan lines in the original footage are stretched to fill up 540 scan lines in the composition.
If you are going to fit DV footage into a square pixel composition you must de-interlace the video by selecting the proper field order. If you do not separate fields the footage will be soft and have a tendency to flicker in areas of high detail. The quality must also be set to "Best" to take advantage of AE's subpixel rendering.
After all editing is complete a new composition is created at 720 X 486 and the edited composition is dragged into the time line. The Fit to Composition option is used again to squish the 540 rows of pixels into 486 rows or scan lines.
Standard Image and Composition settings for DV projects:
The proper standard size for a square pixel composition that is going to be FIT into NTSC DV at 720 X 480 is 720 X 534. For Square pixel artwork that is going to be used directly in an NTSC DV 720 X 480 comp the proper size is 648 X 480. For PAL DV at 720 X 576, the proper square pixel image or comp size is 768 X 576.
For NTSC/DV widescreen at 720 X 480 the square pixel comp size is 856 X 480. For Pal DV Widescreen at 720 X 576 the square pixel comp size is 1024 X 576. Is it any wonder why PAL is the prefered format for up-sizing to Film and HDTV?
The drop dead simple way to work in a square pixel comp is to use 648 X 486 for your SQUARE PIXEL project and then just re-size to 720 X 486 NTSC/DV aspect ratio comp for rendering. AE's automatic pixel aspect ratio mixing capabilities will take over and there will be no re-sizing or Fit to Composition required. Any original DV footage used in the comp will be rendered pixel for pixel. The other drop dead simple way to work in square pixel comps and render to DV is to work with PAL footage. The default project sizes do not require you to fit your footage into the Comp. The pixel aspect ratios take care of the size mismatch automatically. If you're stuck in NTSC land, read on.
Which solution is best? That depends entirely on your footage. Before you can make an intelligent decision you have to understand what is happening to the footage at the pixel level.
Figure 8 is a view of a test image at 400%. The alternating red, white, green, blue and black lines are exactly 1 pixel wide.
Figure 8. Color Test Image.
When the image is placed in a Square pixel composition, every pixel remains unchanged. When the image is placed in a rectangular composition some strange things begin to happen.
Figure 9 is the same image placed in a NTSC DV pixel aspect ratio composition. The quality is set to "Best" to enable subpixel rendering. After Effects stretches the pixels to maintain the proper aspect ratio of the original illustration, but in doing so the vertical color stripes are dramatically changed.
Figure 9. Square pixel footage in a Rectangular pixel composition.
There is also a subtle change in the diagonal lines. After Effects subpixel rendering is responsible for the change in color of the vertical lines. The original square pixel has been stretched to 1.1 times its original width. There is really no way to render a tenth of a pixel so After Effects has to decide what color to make two pixels that contain this oversized pixel and the one next to it. A little math happens and voila, a brand new pair of pixels are created, neither of which are the same color as the original. What does this mean? Why is there no change to the horizontal lines? Are my original graphics going to be all screwed up because I'm mixing pixels aspect ratios? I know! I'll just create a square pixel comp and everything will be just fine.
Not so fast. If you're going to create a square pixel comp and use DV footage it's going to have to be stretched to fill the comp window. You end up a with a new set of problems demonstrated by Figure 10.
Figure 10. Rectangular pixel footage in a square pixel composition.
Now the horizontal lines are fouled up and the vertical lines are ok. Wait. Something strange is going on here. The horizontal and vertical lines are changing dramatically but the diagonal lines look just about the same in both examples. When you mix square and rectangular pixels in a composition something has got to give. New pixels are going to be created in the composition and the original image will be changed.
Figure 12 is the original square pixel image. Figure 13 is the result of fitting a 720 X 540 comp into a 720 X 486 composition. Figure 14 is the result of placing a 648 X 486 image in a 720 X 486 composition. A blue background was used to make it easier to see the the lighter colored pixels that AE creates.
Figure 12. The original image.
FIgure 13. Fitting 720 X 540 into 720 X 486.
Figure 14. Using a Square pixel image in a rectangular pixel composition.
There you go. Now you completely understand subpixel rendering. It looks much more frightening than it is because fortunately, real images used in projects are not made up of repeating patterns of single pixel lines. It is nearly impossible to detect the subtle changes that happen to an image when pixel aspect ratios are mixed. Any time you change the scale of an image, pixel values have to change. It happens in Photoshop and it happens in After Effects. The reason for this little exercise is so you can make a better decision about which level of detail you wish preserve. If horizontal detail is most important, then scale your DV footage up in a 720 X 540 comp, place your square pixel artwork in the composition and then Fit the working comp into a 720 X 486 comp for rendering. If it is more important to you to preserve the scan lines then work at 648 X 486 or directly in 720 X 486. I have included the ColorTest.tif in the project files. I've also included a vector resolution chart called EIA1956.ai. You can experiment with various pixel aspect ratio projects and see how they react. Watch what happens when you switch the quality settings back and forth. You might want to create a short movie of the resolution chart using rectangular pixels and then test working at various square pixel composition sizes. I think you'll be surprised. It takes very careful scrutiny and a scope to see any difference in the resolution of the rendered footage.
A final note: AE defaults to preserving the scan lines with both NTSC and PAL footage. You have to make AE preserve the horizontal pixels by creating an over sized composition and Fitting the footage into your composition. If you work in Pal, you really have no choice. A square pixel Pal comp will hold rectangular pixel pal footage perfectly. There is no forcing required.
I prefer to preserve the scan lines when working on projects where I am not going to de-interlace the footage. Ailiased diagonal lines and artifacts in DV footage tend to be emphasized if you work at 720 X 540 and scale or reposition the footage. I prefer working at the larger comp sizes when there is a great deal of horizontal detail in the graphics. Interlace flicker seems to be reduced because the horizontal edges of my graphics are softened by the automatic compensation that AE makes when the project is forced to the smaller 720 X 486 comp size. If I am working on an television spot and the type has to be 20 scan lines high I always work at 648 X 486. I'm preserving the scan lines and I don't have to do the math to calculate how many scan lines at 720 X 540 equal 20 scan lines at 720 X 486. I also have found that fine text is much less likely to flicker if it is positioned exactly on a scan line. You can't do that when you're going to blend your rows of pixels into scan lines by squishing them from 540 to 486.
The most important thing to remember about all this pixel aspect ratio stuff is that you must know the pixel aspect ratio of your original footage. After Effects will properly mix any combination of pixel aspect ratios from DV Wide Screen to D4/Anamorphic if your original footage is interpreted correctly. Check it with the info at the top of the Project window. If it is wrong, change it. DO NOT create square pixel graphics at standard rectangular pixel footage sizes. Don't change the pixel aspect ratio when you create a new composition unless you have a specific reason to do so. The defaults are correct. You shouldn't have to mess with them. Do this and you can work in any comp with confidence and your pictures will never be distorted.
The project files are here in zip format.
Gerard is a frequent visitor and contributor to the Adobe
After Effects COW. Pop in to comment on this article or ask questions.
Like to see who Rick is and find other articles that he's contributed? Click here.