View Full Version : Saving bitrate through anamorphic encoding
nibus
12th November 2011, 04:15
This is somewhat of a subjective question, but per pixel is it more efficient to encode in anamorphic widescreen rather than in regular square pixels (taking into account end quality)? I've run out of room on my iPad and am looking for ways to cut file size of my encodes while still retaining the same perceivable quality. All encodes are Bluray sourced, so resizing is mandatory.
Consider example 1:
Regular square pixels:
PAR/DAR 608x256 (2.375:1) = 155,648 total pixels
verses example 2:
Anamorphic widescreen:
PAR 544x288 / DAR 688x288 (2.38:1) = 156,672 total pixels
I guess it comes down to where the bitrate is spent - whether more is spent vertically (anamorphic) or horizontally.
So the question is - where is bitrate more effectively spent, on vertical, or horizontal pixels?
akupenguin
12th November 2011, 07:56
Square pixels are most efficient.
Anamorphic wasn't invented for compression efficiency, it was only to shoehorn various aspect ratios into a standard that didn't allow choice of resolution.
Blue_MiSfit
12th November 2011, 11:16
@akupenguin: Interesting comment. While I have no evidence to the contrary, I've definitely heard otherwise.
Why then would formats like HDV and DVCPRO HD use anamorphic encoding? Not that either of these are particularly GOOD standards, but they are fairly common. I'm interested to hear your thoughts.
x264 rev 2106 Parkjoy 4:2:0 8 bit 1080p50
2 pass 5mbps unrestricted VBR, --tune ssim --preset medium
---
1920x1080 Square pixels = .7429623 SSIM mean
1440x1080 Anamorphic = .8087058 SSIM mean
1440x808 square pixels = .8557797 SSIM mean
I would of course expect the SSIM to be higher as we decrease resolution but target the same bitrate. Visually (granted these are tuned for SSIM), the 1440x1080 and 1440x808 versions trade blows. I dunno :p
Derek
Dark Shikari
12th November 2011, 11:51
SSIM is completely meaningless if you're not measuring it at the same resolution. Upscale the results to the same resolutions, then test SSIM.
Secondly, test at a bitrate that isn't completely starved. 1080p50 at 5 megabit on an extremely high-difficulty source is unreasonable.
AnonCrow
12th November 2011, 12:45
So the question is - where is bitrate more effectively spent, on vertical, or horizontal pixels?
If you go into extremes, I think you'll find that 320x64 looks much better visually than 64x320, even
320x32 will look superior to 64x320. At least with block-based video compression.
Dropping the framerate to 1/2 or even 1/3 of the original may be a better choice,
depending on the content. And may not even required full re-encoding.
CarlEdman
12th November 2011, 14:46
I don't think @akupenguin is quite right.
It is correct that square pixels are probably ideal in a general sense and if your source material is square pixel formatted by all means stick with that. It is also correct that anamorphic pixels were introduced kind of as a hack to deal with transport media that did not allow for multiple resolutions.
All that said, we are now stuck with a lot of anamorphic material (i.e., practically every single DVD ever made) and the question is whether you should rescale to square pixels before transcoding. To that I think the answer is clearly no, unless your targeted player can't handle anamorphic material (and it has been a long time since I saw one of those in hardware or software). Rescaling just introduces fake detail and artifacts that the re-encoder has to try to deal with more or less successfully and never perfectly. The result will be a worse file size/quality ratio.
In short, if your source is square pixels, be happy and stay with that; if it has anamorphic pixels, be a little less happy, but stick with that too.
hello_hello
12th November 2011, 16:36
All that said, we are now stuck with a lot of anamorphic material (i.e., practically every single DVD ever made) and the question is whether you should rescale to square pixels before transcoding. To that I think the answer is clearly no, unless your targeted player can't handle anamorphic material (and it has been a long time since I saw one of those in hardware or software).
Normally I'd agree, but I don't think it applies in this case due to the amount of resizing required.
I guess the main idea of anamorphic DVD encoding is to encode "pixel for pixel", so to speak. The minute you start resizing, the benefit of anamorphic encoding probably disappears. I'd guess if you resize by more than a tiny amount, anamorphic encoding could cost you detail compared to using square pixels.
Sharc
12th November 2011, 17:59
Well, I would say anamorphic encoding preserves the resolution of the source material better, given the constraints of the DVD standard resolution (e.g. 720x576 for PAL).
Take for example a movie with an aspect ratio of 1.85:1
Square pixel encoding would store it as 720 x 389 = 280'080 pixels on the DVD and waste a lot of vertical resolution by adding large black borders.
Anamorphic encoding stores it as 720 x 554 = 398'335 pixels which is overall a 42% resolution improvement.
During playback the horizontal 720 pixels are stretched to 1024 (which adds no real details) but the vertical 554 pixels are kept.
If there are however no target format constraints and the source is square pixel (like Blu_Ray) I would encode as square pixel.
CarlEdman
12th November 2011, 18:01
hello_hello makes a good point. Once you heavily resize (as the original questioner was going to), going to square pixels probably does no harm and may do some good.
gyth
12th November 2011, 18:27
Are there any advantages/disadvantages to targeting your encode to an integer fraction of the display screen?
CarlEdman
12th November 2011, 23:08
@gyth: In theory, it might be a slight advantage, but as a practical matter, don't bother.
(1) With the typical anamorphic ratios you see (e.g., 32:27 and 8:9 SAR), you are practically never going to be able to get an integer number of pixels in both dimensions anyway.
(2) More often than not, the renderer will blow up the image to full-screen resolution (which could be pretty much anything from 480x320 for a smartphone to 2560x1600+ for a high-res monitor) anyway, rendering at non-integer pixel dimensions even if theoretically it would be possible to pick an exact set of integer ratios.
If I misunderstood you and you have a specific display resolution in mind and want to encode to an integer fraction of that, again, there might be a slight advantage, but even that will be lost if you ever display the material on a screen of a different resolution. So I'd only bother if I was sure that I'd only ever use one render screen resolution and a specific fraction thereof was a good fit otherwise.
hello_hello
12th November 2011, 23:09
Well, I would say anamorphic encoding preserves the resolution of the source material better, given the constraints of the DVD standard resolution (e.g. 720x576 for PAL).
Take for example a movie with an aspect ratio of 1.85:1
Square pixel encoding would store it as 720 x 389 = 280'080 pixels on the DVD and waste a lot of vertical resolution by adding large black borders.
Anamorphic encoding stores it as 720 x 554 = 398'335 pixels which is overall a 42% resolution improvement.
During playback the horizontal 720 pixels are stretched to 1024 (which adds no real details) but the vertical 554 pixels are kept.
There's no reason why a square pixel encode couldn't be 1024x554 and give you the same vertical resolution as anamorphic 720x554. There's probably nothing to be gained though because there's no more detail for all those extra square pixels to capture.
My point was what happens once you start resizing the video? Once you resize you've basically got a whole new video to encode. All the detail has been "reorganised". Surely when encoding, those extra square pixels are likely to retain more of it?
The OP is really posing a completely different kind of anamorphic question to usual DVD encoding though. One for which I don't really have an answer.
Sharc
12th November 2011, 23:43
The OP is really posing a completely different kind of anamorphic question to usual DVD encoding though.
Yes, I referred to the DVD format just as an example to justify anamorphic encoding.
When there is no target width x height constraint I think square pixel encoding of a square pixel source gives probably the best results, unless the source is very special (more details in vertical than in horizontal direction).
We can imagine extreme cases of anamorphic encoding of the OP's example: 2 x 78000, or 144 x 1080. I dont think the playback would look very impressive.
IanB
13th November 2011, 21:59
This is somewhat of a subjective question, but per pixel is it more efficient to encode in anamorphic widescreen rather than in regular square pixels (taking into account end quality)? I've run out of room on my iPad and am looking for ways to cut file size of my encodes while still retaining the same perceivable quality. All encodes are Bluray sourced, so resizing is mandatory.
Consider example 1:
Regular square pixels:
PAR/DAR 608x256 (2.375:1) = 155,648 total pixels
verses example 2:
Anamorphic widescreen:
PAR 544x288 / DAR 688x288 (2.38:1) = 156,672 total pixels
I guess it comes down to where the bitrate is spent - whether more is spent vertically (anamorphic) or horizontally.
So the question is - where is bitrate more effectively spent, on vertical, or horizontal pixels?
Anamorphic encoding is a form of compression, the aim being to encode less total pixels. Up front you make the choice to discard some horizontal information versus vertical information. In Australia the TV stations transmit hi-def as anamorphic 1440x1080@50i so as to save bandwidth, even so they still squeeze the quality way to hard.
In both your examples you are encoding ~150K pixels, so all other things being equal I would expect similar results in terms of compression artefacts.
Ultimately it depends on the visual entropy of the image in the horizontal and vertical dimensions.
If you want smaller files encode less pixels at a higher quality or encode more pixels at a lower quality, i.e trade encoding artefacts for image resolution.
Anamorphic scaling just gives you 1 more knob to twiddle.
nibus
14th November 2011, 02:13
Thanks for all the replies - after running a couple dozen test encodes, I can confirm that IanB is right. Per pixel, the perceived quality between these two examples or other similar examples is extremely close. If anything, a standard square-pixel encode usually has a slight visual edge over anamorphic encodes in most of the examples I worked with. However, I was surprised at how good anamorphic encodes still look, even with sometimes up to 50% less horizontal pixels. In the end I suppose it also depends on personal opinion.
I'm going to do more tests on smaller resolutions - like 480x208 or 320x208 anamorphic for use on small portable devices. I'm not convinced my findings apply to all circumstances and resolutions.
roozhou
14th November 2011, 03:06
Hi nibus,
Have you tried viewing your encoded video at fullscreen?
nibus
14th November 2011, 05:39
Hi nibus,
Have you tried viewing your encoded video at fullscreen?
Yes, I compared the samples at fullscreen as well as other resolutions. In fullscreen the non-anamorphic samples usually retained better detail.
Blue_MiSfit
14th November 2011, 05:55
Just an update to my post... I just realized how silly it was to use SSIM in the way I did. DOH!
Derek
IanB
14th November 2011, 07:01
When making small dimension encodes the secret is sharpness above all else. The eye and brain imagine (much) more detail is present when the (small) image is sharp.
With DCT based compression accurately representing sharpness usually required more bits per pixel.
E.g. at the same scrimped fixed bitrate, a 320x208 picture may allow more accurate encoding of sharper detail than a 480x208 version.
So with less total pixels there will be more bits available per pixel to represent the image.
Also if you go anamorphic you could use higher sharpness horizontally with less sharpness vertically to crib your total bits per pixel allocation.
Exploring a gamma accurate resizer may be worthwhile for small images.
Dark Shikari
14th November 2011, 09:10
When making small dimension encodes the secret is sharpness above all else. The eye and brain imagine (much) more detail is present when the (small) image is sharp.
"Sharpness" is high-frequency detail. Creating an anamorphic video (from a full-resolution video) means downscaling. Downscaling means lowpassing, that is, elimination of high-frequency details, elimination of sharpness.
By definition, it is mathematically impossible for a (significantly) downscaled video to be "sharp" after upscaling it back to the original resolution, at least if using resize filters intended to be reasonably close approximations of an optimal sinc filter.
IanB
14th November 2011, 10:25
@Dark Shikari,
So very true, there is no substitute for having all the pixels accurately encoded.
The op seems to be interested in small filesize for small display devices. I am advocating sharpness to the point of aliasing for small frame size encodings. Normally I would council against such heresy.
roozhou
14th November 2011, 15:01
Yes, I compared the samples at fullscreen as well as other resolutions. In fullscreen the non-anamorphic samples usually retained better detail.
Are you sure the anamorphic video is not pre-scaled before upscaled to full screen? e.g. 544x288 is first scaled to 688x288 then upscaled to fullscreen.
benwaggoner
22nd November 2011, 05:00
I can't find the reference (Charles Poynton class?) but IIRC, anamorphic was a weird power-of-two artifact from the very first digital processing systems. I think they sampled 768 pixels horizontally (2^9+2^8) to capture the horizontal blanking. When D1 happend, the captured pixels were reduce to 720 to encapsulate the visible area of the screen (which was nominally 704, but they wanted the extra 8 pixels to go blank so there wasn't a high-frequency edge). And so anamorphic sorta crept in by accident. Getting 1080p to be square pixel was actually a relatively last-minute tweak to the ATSC fix.
But yeah, today anamorphic is mainly used for backward compatibilty (I often have an anamorphic 720x480 Level 3.0 as the top SD adaptive streaming bitrate to squeeze the maximum pixels out of mobile decoder hardware possible), or marketing. Although this is rarely said outright, doing 1280x1080 or whatever lets the broadcaster or camera vendor claim "1080!" without having to transmit, record, process, etcetera that many bits. I see a whole lot of "1080" content that would have looked better at a nice square-pixel 720p.
But talking about anamorphic, does x264 do anything to quantization based on the pixel shape? By preserving horizontal and vertical detail relative to the aspect ratio could help preserve sharpness more effectively. If each pixel gets stretched out 50% on the horizontal, keeping more horizontal frequencies will help improve displayed quality.
Dark Shikari
22nd November 2011, 05:55
I you wanted to quantize frequencies in one direction more heavily, use a CQM.
benwaggoner
22nd November 2011, 17:39
I you wanted to quantize frequencies in one direction more heavily, use a CQM.
Sure. But x264 could also tweak automatically based on pixel shape, which it already knows. I imagine it'd give a nice little perceptual quality boost. Most users won't ever use a CQM.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.