View Full Version : Why resize for anamorphic encoding?
hunter_aran
16th February 2012, 21:24
Hi. I'm just trying to understand this better because as I read up on the subject, it seems since anamorphic is just taking a stored image and displaying it differently by stretching or squeezing. If this is a fact, then why would resizing matter at all? Or what are the benefits? I did some videos in handbrake a while back and noticed the strict anamorphic (default option) output a 4:3 video at a resolution but when I put it into iTunes, it lists it as 640x480. Does this mean they were resized by default? Won't resizing decrease quality of the source? My avisynth/megui encoded videos look fine but the resolution is not listed as 640x480 when I put it in iTunes. It lists it as the original (assuming non-anamorphic) resolution. It displays fine but I'm just wondering if this could cause any problems?
Lyris
16th February 2012, 22:22
Won't resizing decrease quality of the source?
Yes.
Resizing anamorphic(non-square) video is generally done to avoid playback issues on computer screens (1:1).
FWIW, Apple products sometimes display the resolution AFTER their player has scaled it - Quicktime on the Mac does this, I don't know if iTunes does too. For example, Quicktime will report the "resolution" of a 720x576 PAL Widescreen MPEG2 clip as "1024x576" which it is not!
hunter_aran
16th February 2012, 23:16
Yes.
Resizing anamorphic(non-square) video is generally done to avoid playback issues on computer screens (1:1).
FWIW, Apple products sometimes display the resolution AFTER their player has scaled it - Quicktime on the Mac does this, I don't know if iTunes does too. For example, Quicktime will report the "resolution" of a 720x576 PAL Widescreen MPEG2 clip as "1024x576" which it is not!
So what you're saying is that as long as the video displays correctly, since different programs report resolution differently, that I just shouldn't worry about it, right? Well that's good news. I still don't get what Handbrake is doing differently to get the video resolution reported at the correct playback resolution of 640x480 and why ones through megui are not. One that I cropped shows as 704x537, another 712x539 but displays correctly. But I just checked Quicktime and it says the correct display resolution minus any cropping I did. I originally wanted to create videos that look the same as if they were bought from iTunes. I'm just picky I guess and want to make sure I didn't mess anything up.
Sorry for the double post, stupid phone browser!
roozhou
17th February 2012, 03:41
IMO PC has less issues with anamorphic videos than other devices, especially when playing AVC videos.
hello_hello
17th February 2012, 06:51
hunter_aran, are you using a Mac? I know nothing about Mac software, but Media Player Classic Home Cinema will display the actual resolution along with the aspect ratio. Something like "720 x 428 (AR 1023:428)", or "720 x 480 (AR 16:9)" etc.
For PC: http://mediainfo.sourceforge.net/en
For Mac: http://mediainspector.massanti.com/ or http://www.pozdeev.com/invisor/
Handbrake and MeGUI may store the aspect ratio in the container differently, which can be different to the way the aspect ratio is written to the video stream, and one of them may write the aspect ratio as 640x480 while the other writes it as 4:3 etc, and different players probably interpret it in different ways, or depending on the player settings it might obey the video stream aspect ratio rather than the container aspect ratio.... all for the same video. It should always display with the correct aspect ratio, but maybe at a different size.
Normally when encoding though, the video stream and container aspect ratio would be the same, but they might be stored differently (4:3 vs 640:480 etc).
Resizing when encoding anamorphically is a different thing to the way the video is resized on playback. I don't use Handbrake but I'd assume "strict anamorphic" is the same as MeGUI's "encode non-mod16" option. In other words if you take a 720x480 video and crop 2 pixels from each side it'll be encoded as 718x478. In the case of MeGUI, the only anamorphic option which resizes while encoding is the "resize to mod16" option. It'll take your cropped 718x478 video and resize it back to 720x480 etc (mod16 dimensions) while adjusting the display aspect ratio to suite.
MeGUI's "acceptable aspect error" setting tells MeGUI how much it's allowed to fudge the aspect ratio in the process. It's set to 2% by default, probably to allow you to achieve nice 4:3 or 16:9 aspect ratios more easily. Setting it to 0% will cause MeGUI to change the aspect ratio exactly when using the "resize to mod16" option so as not to distort the picture at all.
Thinking about it, maybe Handbrake's "strict anamorphic" enforces mod16 dimensions as MeGUI's "resize to mod16" option does. I don't know....
PS. The main reason for resizing when encoding anamorphically is for hardware compatibility (mod16 dimensions) but these days it's fairly irrelevant. Non-mod16 encoding is fine. A PC won't have a problem with it and none of the media players in this house care.
Remicade
17th February 2012, 09:04
x264 encoding is optimised for 16x16 blocks ?
hello_hello
17th February 2012, 10:47
I guess so, but the way I understand it, and admittedly I don't think I've run comparison encodes myself, there's no major efficiency drop using the x264 encoder as there was (may have been?) with older types of encoders.
I guess it's a trade-off anyway. If you resize to mod16 then you're resizing, which starts to defeat the purpose of anamorphic encoding a little (Although I've compared slightly resized encodes with non-resized encodes and can't see any difference. It's not like DVDs look crystal clear anyway), or you can crop extra to achieve mod16 and lose some of the picture....
As a rule I tend to try to stick to a mod4 width as I often re-encode my encodes as AVIs to use on other players, and for whatever reason mod2 seems to upset the process, although that's probably just due to the way I go about it. The height doesn't seem to matter. When it comes to playback I've not had any problems using any non-mod16 resolution.
Chetwood
18th February 2012, 08:29
If I understand Brother John's Staxrip guide correctly, the point of anamorph encodes is that there's no resizing but only cropping? So you crop all sides to remove the black bars and keep this size, MOD4 should make no problems for X.264.
J_Darnley
18th February 2012, 11:18
Please stop spreading misleading information. x264 can and will encode any correct resolution you can give it. The only limitations x264 has relate to chroma subsampling.
Brother John
19th February 2012, 18:07
As long as we’re talking about H.264, forget mod16. What you need is mod2 because the YV12 colourspace requires that. The encoder does have to pad non-mod16 to the next larger mod16 internally, but the efficency loss due to that is negligible. Also remember that even the most normal thing in the world, 1080i/p, it not mod16.
Chetwood is right, btw. Generally speaking an anamorphic resolution of area X has a similar level of image detail to a non-anamorphic resolution of area X. I.e. an anamorphic destination resolution is great because you can avoid to resize (which is always lossy) altogether, not because anamorphic is superior. This also means you should not use any encoding mode that crops to non-mod16 and then resizes back to the nearest mod16. That defeats the purpose of skipping the resize and will lose some quality.
benwaggoner
21st February 2012, 19:33
As a rule of thumb, I'll encode anamorphic unless I have a specific reason not to. Most players will handle it correctly these days, and doing otherwise just wastes pixels or bits.
hunter_aran
22nd February 2012, 07:36
Ok I appreciate all the info and it really has helped convince me anamorphic is the way to go and not to resize or bother with mod16. ;)
I found an article that seemed informative on exactly how Handbrake creates the "strict anamorphic" feature. Maybe someone could elaborate on how to use MeGUI, MP4Box, or whatever to create the same effect--create anamorphic video but that sends the correct display information as far as iTunes, Quicktime, and iDevices are concerned.
"The smart way of handling anamorphic is to store the display information in the video track. And this is exactly what HandBrake does'
Ok so Handbrake puts the AR in the stream, which is what I thought MeGUI does too...
"By default, the PAR is 1:1. With that ratio, what you see is what you get—square pixels. The video is stored and displayed with the same dimensions. In order to recreate 16:9 pixels from 1:1 pixels, the ratio is 32/27 (16*2 / 9*3). For every 32 square pixels across, it uses 27 square pixels up and down. You already know this, another way: it produces the same results as multiplying the height (480) by 16/9. Multiply 720 by 32 and divide that by 27, and you end up with 854, the display width in square pixels"
So the PAR is 1:1 and the 32/27 mentioned above is the same as the DAR that you put in MeGUI's "clever anamorphic" right? Or is that the SAR that can be put in an X264 encode manually (under x264 settings in MeGUI)?
A small problem is that I've been using MP4Box to correct the PAR on some files where the AR got messed up recently, so since the PAR is 8:9 on those files, then that is not what I want to do if I want to use the same approach as Handbrake then...
"In order to preset anamorphic video in QuickTime, HandBrake adds extra display information to the .mp4 container wrapping the video, called a picture aspect atom. This is different from the information in the video stream, but achieves the same effect. In this manner, HandBrake creates anamorphic video that can be displayed with QuickTime, as well as with iPods, as well as with iPhones, as well as with AppleTVs, as well as with open source video players like VLC and MPlayer."
Ok! This is different! What is this Picture Aspect Atom? This probably explains how all these Apple softwares are reading the resolution as 640x480 even though it really is not. Any ideas how to recreate this in MeGUI or any muxer? This is probably exactly what I was looking for!
hunter_aran
25th February 2012, 01:06
Nvm, I think I got my question answered in an older thread I found. The thing I was looking for was this "pasp" atom, which is added in the mp4 container by multiplexers like Mp4box and Mp4muxer. Mp4Box allows you to specify the PAR in the stream and Mp4muxer lets you enter the final output resolution and put that in the stream (DAR I'm assuming). Doing this in either program makes quicktime / iTunes display it correctly as well as report the output resolution correctly at the scaled size just like Handbrake. I just ran through a particular file in Handbrake to test and it sets PAR as 8:9 as well as the correct scaled size and so my guess is that using YAMB with Mp4box creates a file (seemingly) identical to the one handbrake outputs since it uses the PAR method of AR signaling.
hello_hello
27th February 2012, 11:52
So the PAR is 1:1 and the 32/27 mentioned above is the same as the DAR that you put in MeGUI's "clever anamorphic" right? Or is that the SAR that can be put in an X264 encode manually (under x264 settings in MeGUI)?
I'm not sure if you're going about it the correct way. When you open a DVD with MeGUI it'll default to the appropriate aspect ratio. It has a setting to tell it whether to default to ITU resizing or not (I generally don't use ITU resizing but if you do the difference in the way the DVD is re-sized isn't all that great) so depending on the setting it'll either default to a 4:3 or 16:9 aspect ratio.... or to an ITU 4:3/16:9 aspect ratio.... and if you've told MeGUI to default to ITU resizing it'll pick either PAL or NTSC, otherwise it'll just display 16:9 or 4:3.
DVDs are either 16:9 or 4:3, there's no other DVD aspect ratios.
From there you do your cropping and if you want anamorphic encoding without any resizing, you tick the "anamorphic encoding" option and select any of the anamorphic options except for the "resize to mod16" one. "Encode non mod16" should be fine.
Now if you switch to the "Script" tab you'll see the calculated display aspect ratio near the top. Change the cropping a bit, switch back to the script tab and you'll see the display aspect ratio has been changed accordingly.
Don't use the "Force SAR" option in the x264 configuration dialog. Just leave it at "default" and MeGUI will do the math for you, writing the correct aspect ratio to both the video stream and container. Whether iTunes needs something "special" and what "atoms" are I don't know, but following the above method should get your video displaying with the correct aspect ratio. MeGUI also has a setting for QT compatibility although I'm not sure what it does exactly.
The "PAR 1:1" thing you quoted earlier explains what happens if you encode using square pixels. You take a 720x480 16:9 DVD, stretch the picture out to the correct aspect ratio and in square pixels terms it'll be about 854x480. Nothing to do with anamorphic encoding, which encodes the video using the original 720x480 dimensions (cropping aside) and stretches it to the correct aspect ratio on playback just like the original DVD.
Just remember the aspect ratio being displayed when you open a DVD is the "input" aspect ratio. Either 16:9 or 4:3. If you use anamorphic encoding and don't crop then the "output" aspect ratio should be the same as the input (actually if you use ITU resizing it won't be exactly 16:9 or 4:3). When you crop, MeGUI re-calculates the "output" aspect ratio which is displayed under the Script tab.
Ok! This is different! What is this Picture Aspect Atom? This probably explains how all these Apple softwares are reading the resolution as 640x480 even though it really is not. Any ideas how to recreate this in MeGUI or any muxer? This is probably exactly what I was looking for!
Someone else may have to explain "Atoms". I'm fairly sure they only apply to MP4s (or maybe M4Vs) and they're an "Apple" thing. I'm also fairly sure MeGUI will output MP4s which iproducts can display correctly if you follow the above procedure. Assuming of course all iproducts support anamorphic video. I don't know as I've never owned one, but some devices assume that everything uses square pixels and will display the video that way no matter what you do.
hello_hello
27th February 2012, 11:54
PS. All of the above applies to encoding a video with MeGUI using the Script creator. No doubt the one-click encoder will encode anamorphic video correctly but I don't know the procedure as I've never used it.
SeeMoreDigital
27th February 2012, 20:29
For quite a few years now I've been using DVBPortal's MP4Muxer, which utilizes mp4creator.exe (dated 2011-08-04) to specify the .MP4 "containers" resolution, for use with Quicktime player.
Works a treat ;)
killmoms
20th June 2012, 17:58
For quite a few years now I've been using DVBPortal's MP4Muxer, which utilizes mp4creator.exe (dated 2011-08-04) to specify the .MP4 "containers" resolution, for use with Quicktime player.
Works a treat ;)
Subler is a great solution for this on the OS X side, I use it to create anamorphic MP4s that play correctly on iDevices, Macs and PCs.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.