Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange behavior with MKV crop flags #328

Closed
mhendu opened this issue Nov 24, 2023 · 8 comments
Closed

Strange behavior with MKV crop flags #328

mhendu opened this issue Nov 24, 2023 · 8 comments

Comments

@mhendu
Copy link

mhendu commented Nov 24, 2023

Most MKV files that I've seen have the Video display width / height flags set by default (most commonly to the same as the pixel width / height). When adding crop flags (Video crop left / top / right / bottom) to the metadata MPC-BE seems to apply these flags in an unexpected way, such that the crop flags are applied first, then the display width / height flags, so a letterboxed video (black bars on top / bottom) will appear vertically stretched.

When rendering via MadVR, the player appears to create a frame with the video's dimensions, then places the video at the bottom of the frame so there's a larger black bar across the top.

What should happen (I think) is that the player should independently apply the crop and display flags to the video's actual dimensions. For example, I have some videos where the display flags were set to stretch the video horizontally, but that also have crop flags to remove black bars at top / bottom. The player should read the display flags to determine the aspect ratio, then use the crop flags to remove the black bars. This behavior should be consistent for the internal renderer and MadVR.

@v0lt
Copy link
Collaborator

v0lt commented Nov 24, 2023

The player does not crop the frame.
The player sets the cropping parameters (as Microsoft came up with) and passes them on to the video renderer. If you think that some video renderer is cropping the frame incorrectly, then compare the result with the result of the Enhanced Video Renderer (EVR).

There is no madVR support here.

@mhendu
Copy link
Author

mhendu commented Nov 25, 2023

OK, maybe it's a video renderer problem. Here are a few example frames so you can see the issue. In this case the video file has display flags set to 3840x2160, with crop flags of 262 pixels on the top and 260 pixels on the bottom.

Via Enhanced Video Renderer (vertically stretched):
western mkv_snapshot_00 47 53_ 2023 11 24_17 47 39

Via MadVR (black bar across the top):
western mkv_snapshot_00 47 53_ 2023 11 24_17 49 48

Via PotPlayer with EVR (displays as expected, correct aspect ratio with black bars cropped)
Western mkv_20231124_175144 916

@v0lt
Copy link
Collaborator

v0lt commented Nov 25, 2023

Via PotPlayer with EVR (displays as expected, correct aspect ratio with black bars cropped)

This has not been proven.

  1. No one has seen your MKV sample except you.
  2. There was no analysis of the parameters of your file, the MKV specification and the results obtained.

@mhendu
Copy link
Author

mhendu commented Nov 25, 2023

Thanks, I can provide a MediaInfo export if that helps, but I do see from the specs you shared that it's expected that crop flags are applied before the display width / height is determined. The problem there is that most players don't support crop flags, but many do support display width / height flags, so adjusting the files to conform to the specs means that they won't display properly in most players. Plex, or VLC, or MPC-HC, for example, all display incorrectly if I adjust the display height to take into account a crop flag at top / bottom. PotPlayer rendering w/ EVR does seem to handle correctly, which is interesting considering that it also displays what I expect when the display flags are set to match the video resolution.

Maybe this is a behavior that the user could select in MPC-BE? That would allow the player to conform to specs but also enable it to handle these other scenarios if required.

@v0lt
Copy link
Collaborator

v0lt commented Nov 25, 2023

Thanks, I can provide a MediaInfo export if that helps

The MediaInfo report is no good. You need a small sample of 20 seconds (preferably up to a minute).

The problem there is that most players don't support crop flags, but many do support display width / height flags, so adjusting the files to conform to the specs means that they won't display properly in most players.

This is not an MPC-BE problem. This is a problem with other players.

Plex, or VLC, or MPC-HC, for example, all display incorrectly if I adjust the display height to take into account a crop flag at top / bottom.

MPC-HC uses LAV Filters, which does not support frame cropping.

@mhendu
Copy link
Author

mhendu commented Nov 26, 2023

OK, thank you. I've subscribed to the request for MPC-HC, but would be great to see the ability to apply cropping secondarily in MPC-BE. If it helps to have a sample file, how would you like to receive it?

@Aleksoid1978
Copy link
Owner

Upload sample here

@Aleksoid1978
Copy link
Owner

I'm closing it because the example file is still missing.

@Aleksoid1978 Aleksoid1978 closed this as not planned Won't fix, can't repro, duplicate, stale Dec 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants