Ashyni / mpv-scripts

dynamic-crop.lua script for mpv player/lib.
MIT License
81 stars 4 forks source link

The script of dynamic-crop.lua has incorrect crops on some video scenes. #11

Closed dyphire closed 2 years ago

dyphire commented 2 years ago

Setup:

Additional context Only use dynamic-crop.lua to test.

Describe the bug

  1. In videos with fast changing black bars, the script sometimes can't recognize the changes of black bars in time, so as to cancel the vf filter.
  2. In videos with normal upper and lower black bars, scripts sometimes incorrectly crop the video, causing the video to move down.

Expected behavior The script can handle these video scenes correctly

Screenshots For the first scene:

For the second scene:

These are test video: https://1drv.ms/u/s!ArMFy8JIhLKH51msuqyLi4q0xIjf?e=vSYLXg The first bug appeared in the video of crop1.mkv at 00:01:13.167. The second bug appears after 00:00:50.509 in the video of crop2.mkv.

Ashyni commented 2 years ago

Hello, for the video crop1.mkv at 00.01.13, i can't do anything, it's dark and really fast, there is no reliable data to work with. Same thing happen on credit scene, it's a compromise to make.

For the video crop2.mkv, looks like the black on top is not the same as the bottom one, the auto limit settle on stable data and the script eventually add that as a new offset. I had something in place at a moment for this rare case of different dark color, i did not reintroduce it when i have rework the script on event base. I will work on it when i can and push it when i'm sure it doesn't interfere with something else, no promises.

Thanks for the video samples provided, i keep crop2.mkv to work on it.

dyphire commented 2 years ago

I will work on it when i can and push it when i'm sure it doesn't interfere with something else, no promises.

I look forward to you can finding a reliable way to deal with this kind of issue.

it's dark and really fast, there is no reliable data to work with.

For reference only, when the zoom control option of madvr is set in the following way, it can correctly handle these video had fast black bars.

I'm not sure if this can be used as an effective reference, because madvr is very different with mpv.

Ashyni commented 2 years ago

Case 1 and 2 handled by https://github.com/Ashyni/mpv-scripts/commit/c85a0b163f12e6fe0645a868e16585d57854fa23 For the fastest reaction for case 1 you can tweak the following, but can't promise fast_change_timer will not generate some false positive. (change default 1 to 0.1 with the commit)

script-opts-append=dynamic_crop-detect_skip=1
script-opts-append=dynamic_crop-fast_change_timer=0

Closing the issue.

dyphire commented 2 years ago

Case 1 and 2 handled by c85a0b1. Closing the issue.

Thanks. It works.

However, modes 1 and 3 now do not clear the video filter when playing the next file.

Ashyni commented 2 years ago

Sorry about that, fix in https://github.com/Ashyni/mpv-scripts/commit/f122f381fcac24257f62f53d7870bac52511cacb.