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. |
|
![]() |
|
Thread Tools | Search this Thread | Display Modes |
![]() |
#1 | Link |
Registered User
Join Date: Oct 2013
Posts: 229
|
Handbrake is creating a bad reencode based on a 4K video
I posted in the MPC thread that I tried using Handbrake to reencode a 4K video (not from a UHD/4K disc) into regular H.265, FPS same as source, again in MKV, with a 5000 (bitrate) and all the rest set to default.
Also, I created a copy with the video only, to make things easier, of the original (bigger) file. This is what the 4K OG video was: https://pastebin.com/NTQmzvUT And this was the end result: https://pastebin.com/5Usja10a I explained the following to chatGPT: Subtitles were stretched, when I added to the reencoded video. Only by turning off this: "Apply aspect ratio compensation for anamorphic videos" They were OK. This option was always enabled by default, in MPC-HC. Then I was told this: ++++++++++ Here's an analysis of the differences between the original and re-encoded video files, focusing on why the re-encoded file has playback issues in MPC-HC and requires adjusting the "Apply aspect ratio compensation for anamorphic videos" setting. 1. Key Differences Between the Files Video Encoding Format Original: AVC (H.264) with High@L4.1 profile. Re-encoded: HEVC (H.265) with Main@L4@Main profile. HEVC is more efficient at compression but can sometimes cause compatibility issues with older players or renderers. Video Dimensions Original: 3840x2160 pixels (4K UHD) with an aspect ratio of 16:9. Re-encoded: 1920x1080 pixels (Full HD) with an aspect ratio of 2.35:1. Impact: The re-encoded file has a lower resolution and a different aspect ratio, requiring the player to make additional adjustments for proper display. NOTE (I forgot to explain before): - The original content is in Wide 2.35:1. ChatGPT explained further: ++++++++ Sample Aspect Ratio (SAR) Original: Doesn't rely on SAR adjustments; uses a standard display aspect ratio (DAR) of 16:9. Re-encoded: Specifies a SAR of 255:360, which is unusual and likely incorrect. Impact: The odd SAR value in the re-encoded file can mislead the MPC-HC into applying unnecessary aspect ratio corrections, treating the video as anamorphic. ++++++++ From where does this come from? Since I set everything as default (max res to 1080p, not 2160p) in HANDBRAKE? ++++++++ Bitrate Original: 60 Mbps. Re-encoded: 4,999 kbps. Impact: The drastic reduction in bitrate may reduce video quality, but it doesn't directly cause the playback issue with aspect ratio. +++++++++ Encoding Library Original: Encoded with x264 core 163. Re-encoded: Encoded with x265 4.1+1. Encoding with HEVC (x265) introduces specific metadata, such as the incorrect SAR, that older renderers or settings may interpret incorrectly. +++++++ 2. The MPC-HC Setting: "Apply Aspect Ratio Compensation for Anamorphic Videos" This setting automatically adjusts videos with anamorphic properties or unusual SAR values to display correctly. For the re-encoded file: The SAR value of 255:360 triggers this adjustment unnecessarily. Disabling the option resolves the issue for this specific file but could potentially impact other videos that genuinely require this compensation. ++++++++ 3. The Root Cause The incorrect SAR value (255:360) in the re-encoded file is the primary issue. This causes MPC-HC to treat it as anamorphic, triggering aspect ratio compensation that distorts the playback. The HEVC metadata may also contribute to this misinterpretation, as it's more sensitive to inconsistencies compared to AVC. +++++++++++++ Then, I was offered a solution... 4. Solution Fix the SAR in the Re-encoded File To correct the SAR without re-encoding the video, use ffmpeg: The code: Code:
ffmpeg -i reencoded.mkv -c copy -vf "setsar=1" corrected.mkv 2. Adjust the MPC-HC Settings Temporarily, you can disable "Apply aspect ratio compensation for anamorphic videos" in MPC-HC settings. However, this might cause issues for other anamorphic videos. 3. Use an Advanced Renderer Consider switching to a renderer like madVR or similar, which handles HEVC metadata and unusual SAR values more gracefully. ++++++++ NOTE: I always used madVR. +++++++ 5. Conclusion +++++++ The playback issue with the re-encoded file is caused by its incorrect SAR value (255:360), not just the re-encoding itself. Fixing the SAR to 1:1 using ffmpeg will resolve the problem without needing to alter MPC-HC's global settings or affect other files. +++++++ My conclusion is that ChatGPT is wrong, because running that command mentioned in step #4 will probably not work without a reencode. So, I spent hours reencoding this, for nothing? And need to do this from scratch? I don't think ffmpeg will fix this in 2 minutes as suggested above, just like MKVTOOLNIX isn't, if I select a new display AR like 16/9 or 2.35 for the file (with no reencode) What needs to be done here? I reencoded 1080p files before, and this was the 1st time subtitles were displayed like that. These were the HANDBRAKE options I used: https://i.postimg.cc/x1vGNBT7/OP1.jpg https://i.postimg.cc/F9bGYkYR/OP2.jpg https://i.postimg.cc/R0v77GW0/OP3.jpg https://i.postimg.cc/6QzdYRZf/OP4.jpg If there was a single mistake (besides some personal choices), I am not seeing anywhere in HANDBRAKE. The goal was to reencode into a H.265 file, with a bitrate of 5000, in regular H.265, and that's it. FPS = same as source, again as MKV, and nothing more. P.S. I tried a reencode with another 4K file totally different, and the same problems were repeated. |
![]() |
![]() |
![]() |
#2 | Link |
Registered User
Join Date: Oct 2013
Posts: 229
|
I figured out what was the problem with the reencode. "Anamorphic" needs to be turned off, completely (in HANDBRAKE settings).
If it's on (automatic), the "pixel aspect" will not be 1:1. Instead, it can be something like 45:34, and below we will see the video will be probably created at 1920x1080 with the 2.35:1 aspect ratio (original res. was 3840x2160, and this is not taken from a 4K-UHD disc, it's a regular video), but on the left side it will appear the "display size" is 2541. Scaled size to become 1920x1080. This is how it was been reencoded, creating the stretched subtitles: https://i.postimg.cc/ZTxkBBSq/BEFORE.jpg And this is how it appears after I changed: https://i.postimg.cc/zJrZGw4M/AFTER.jpg Also, it's consistent the resolution was reduced to 1920x832, with other files I saw on the internet. I was telling the reencode to be 1920x1080 no matter what, but this caused the anomaly in the 1st place. I checked the new reencoded file with subtitles, and they were displayed correctly. Even with the "Apply aspect ratio compensation for anamorphic videos" in MPC-HC settings, ENABLED again. So this is the solution. Mental note: my chosen bitrate was 5000, using HANDBRAKE. Last edited by Perenista; 23rd January 2025 at 21:00. |
![]() |
![]() |
![]() |
Thread Tools | Search this Thread |
Display Modes | |
|
|