Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
![]() |
#1 | Link |
Compression mode: Lousy
Join Date: Mar 2009
Location: Hamburg, Germany
Posts: 72
|
x264 letterbox border detail loss
When encoding videos with a top letterbox size that is not a multiple of 16 there often is some noticable loss of detail within the first few lines.
This happens especially with sources containing grain and weirdly only if the runtime is longer e.g. a trailer encode will be ok but a full feature encode isn't. For example if you have a 1920x1080 source with a top letterbox of 132 pixels (2.35:1) the first 12 lines of active picture seem blurred or not as detailed as the rest of the picture. The obvious solution is to shift the picture up or down a few pixels to the next macroblock border. This might be ok with a large letterbox but if you have a small letterbox like 20 pixels (1.85:1) the viewer will notice the picture is not centered. Can you think of any other solutions to this problem? Settings: --preset slower --keyint 24 --slices 4 --bitrate 30000 --vbv-maxrate 40000 --vbv-bufsize 30000 --level 4.1 --bluray-compat Last edited by kabelbrand; 14th October 2013 at 16:16. |
![]() |
![]() |
![]() |
#2 | Link |
Software Developer
![]() Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,245
|
Why not crop away the black borders completely?
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊ |
![]() |
![]() |
![]() |
#5 | Link |
Software Developer
![]() Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,245
|
Just an idea: Might this be related to Psy-RDO/Psy-Trellis? Those try to retain the same "complexity" in each compressed block as in the original block. Now, if you look at those blocks directly on the border between the content and the "black" area, about 1/2 of the block is just 100% black, which means zero complexity in that part of the block. Overall, these blocks probably are strongly biased to look like "low complexity" blocks to the encoder. So Psy-RDO/Psy-Trellis will try to keep them "low complexity", which might explain the blurring - even in the part of the block that is not 100% black.
Other than that: Have you tried with and without MB-Tree enabled?
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊ Last edited by LoRd_MuldeR; 14th October 2013 at 14:18. |
![]() |
![]() |
![]() |
#6 | Link | ||
Compression mode: Lousy
Join Date: Mar 2009
Location: Hamburg, Germany
Posts: 72
|
Quote:
Quote:
Yes. While it makes fades look a bit better there is no quality gain at the letterbox border. |
||
![]() |
![]() |
![]() |
#7 | Link |
Registered User
Join Date: Sep 2007
Location: Europe
Posts: 602
|
kabelbrand, I had this exact same problem - a very textured film with borders top and bottom, and the grain would get stripped away inside the block with the black border.
As you say, with large letterboxing you can just shift the image a little, but with thin strips top and bottom, that'd look odd. Jason and Kieran pointed me to the solution: AQ. From my experience, the setting you need to adjust is --aq-strength. The default is 1.0. --aq-strength 0.5 or so should resolve this to a satisfactory extent, although I believe the trade-off is coarser compression in dark areas (although you'd have to crank up the brightness and/or gamma on a badly adjusted TV for this to really be a problem). Last edited by Lyris; 14th October 2013 at 14:57. |
![]() |
![]() |
![]() |
#8 | Link |
Software Developer
![]() Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,245
|
Shouldn't AQ tend to improve those blocks located directly on the border?
![]() About 1/2 of these blocks is pure black, so those blocks should be biased to appear relatively "flat". And, AFAIK, the VAQ algorithm moves more bits into "flat" blocks, whilst taking away bits from "complex" blocks...
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊ Last edited by LoRd_MuldeR; 15th October 2013 at 00:08. |
![]() |
![]() |
![]() |
#11 | Link | |
Compression mode: Lousy
Join Date: Mar 2009
Location: Hamburg, Germany
Posts: 72
|
Quote:
Anyway... Thank you all! |
|
![]() |
![]() |
![]() |
#12 | Link | |
Moderator
![]() Join Date: Jan 2006
Location: Portland, OR
Posts: 4,578
|
Quote:
For example, a 1920x1080 source with 140 pixels of black on the top and bottom. 140 isn't mod16. So you could move it down slightly to have 144 on the top and 136 on the bottom, both of which are mod16* aligned. *"1080p" is really encoded as 1920x1088 pixels with the bottom 8 of dummy data that isn't displayed. So that 136 is really 136+8=144 which is mod16. The key thing is that the bottom black bar starts at 944 pixels from the top, which is mod16. |
|
![]() |
![]() |
![]() |
#13 | Link |
Compression mode: Lousy
Join Date: Mar 2009
Location: Hamburg, Germany
Posts: 72
|
Cropping/Padding to the next multiple of 16 is what I was doing in the past and I just wondered if there was a better way.
I even tried to add an additional 4 black lines to the top and explicitly set the bitstream cropping rectangle to crop these instead of the bottom 8 lines for 1088->1080 to have that 140 letterbox aligned with macroblock boundaries but this did not work as I expected and I ended up with weird resolutions like 1920x1076. At least with decent bitrates the bottom border does not seem to be problematic with x264. Last edited by kabelbrand; 15th October 2013 at 11:52. |
![]() |
![]() |
![]() |
#14 | Link | |||
Moderator
![]() Join Date: Jan 2006
Location: Portland, OR
Posts: 4,578
|
Quote:
Quote:
Quote:
|
|||
![]() |
![]() |
![]() |
#15 | Link | |
Compression mode: Lousy
Join Date: Mar 2009
Location: Hamburg, Germany
Posts: 72
|
Quote:
Then encode using "--crop-rect 0,4,0,4" which should signal the playback software to discard the top and bottom 4 lines to render a 1080 picture. Unfortunately this won't be usable for Blu-ray Disc because the specification allows cropping at the bottom only. Other software seems to ignore "frame_crop_top_offset" in the SPS as well: PowerDVD, VLC, DGIndexNV Last edited by kabelbrand; 16th October 2013 at 13:41. |
|
![]() |
![]() |
![]() |
#16 | Link | |
Moderator
![]() Join Date: Jan 2006
Location: Portland, OR
Posts: 4,578
|
Quote:
|
|
![]() |
![]() |
![]() |
#17 | Link |
Registered User
Join Date: Dec 2002
Posts: 5,565
|
I don't see anything wrong with kabelbrand's last post.
![]() Last edited by sneaker_ger; 16th October 2013 at 22:39. |
![]() |
![]() |
![]() |
#18 | Link | |
Compression mode: Lousy
Join Date: Mar 2009
Location: Hamburg, Germany
Posts: 72
|
Quote:
![]() Encoding a 1080 source with x264 is actually as good as encoding a 1088 source with "--crop-rect 0,0,0,8" specified. Both are ok for BD - x264 (and other encoders) will repeat the last line of the 1080 source 8 times to fill 68 macroblocks vertically (1088 pixels) and specify 8 pixels bottom cropping at bitstream level internally. But as I said, specifying bitstream cropping other than at the bottom is illegal for BD. Sadly... |
|
![]() |
![]() |
![]() |
Tags |
detail, letterbox, macroblock, mod16, x264 |
Thread Tools | Search this Thread |
Display Modes | |
|
|