Closed zettai-karen closed 7 months ago
I have noticed that while the pixel format conversion prevents colors turning into grayscale, it can slightly mess up the colors. The effect is small and rare enough to ignore, however (in my opinion).
Sorry github didn't notify me about this for some reason.
I'm a bit confused here though. What "undesirable scaling" was occurring and how does this fix that? With regards to pixel format, I presume it's related to #21? You could just add an additional vf filter to blindly convert everything to yuv420p and it wouldn't do that although I didn't want to add yet an extra filter.
With the attached two pages, double page mode causes the first page to become blurry even when the output has the same height as the first page (while making this file I just noticed that with this example it only happens in manga mode). mikami-scaling-test.zip
And concerning the pixel format issue: Yes, I tried to deal with the one described in #21 as I have been annoyed by that problem for a while. My "solution" was also to add a format filter to every input page, for which I chose yuv444p (pretty much randomly, I honestly know very little about color). Unfortunately this makes the code quite a bit more ugly, but I know next to nothing about ffmpeg and don't know a way to write the filters elegantly.
With the attached two pages, double page mode causes the first page to become blurry even when the output has the same height as the first page
With this particular example, there are multiple format conversions for whatever reason. pal -> argb and then when using double page (lavfi complex), it is rgb24 and the resolution is 1511x1200 instead of 1506x1200. To my eyes, it's not hugely different, but that weirdness is certainly the cause of whatever you're seeing. I don't know why it is happening here with that particular sample. If you have something that is normal (say 2 yuv420p images), it should be OK.
My "solution" was also to add a format filter to every input page
You can add a vf filter to lavfi-complex to do it. The ideal way to handle this imo is when two pages have differing pixel formats, you add a vf filter so it's converted to the "highest" format (yuv444p, yuv420p or whatever it is). The problem is that mpv doesn't have a property currently to detect this ahead of time, so I never got to implementing this. For anything that's decoded by lavfi demuxer (which will be like 99% of things in practice), this is easy to implement. Just never got around to it.
I've replaced my complicated ugly solution with the most minimal one I could think of that includes both a solution to the color problem and to the scaling problem. It's not ideal (theoretically, with the new code and a 1080 px high output/screen, a pair of one 1080 px and one 1200 px high pages will cause the 1080 px high page to get upscaled to 1200 px and the downscaled to 1080 px again), but I think that theoretical issue is already present in the current main program so it's only a lack of a fix instead of a new issue. And I think the similar height threshold needs to be increased (I have at least one manga on my hard drive where in the middle a single page suddenly is almost 200 px smaller than the rest).
I've noticed that even grayscale values can get changed with this method, that's pretty annoying. grayscale_test.zip
With 6b65d98be7d20c8e272a4caa6c5018ed3a8bb2b3 and mpv master, the gray format conversion issue should finally be fixed. I will close this since as far as I'm aware, that was only real bug this was trying to fix.
Converting every page's pixel format explicitly instead of implicitly fixes the inconsistent pixel format issue. Allowing user to choose scaling/padding behaviour and making scaling behaviour more consistent. More importantly, removing blurring issues stemming from undesirable scaling that was present. Querying "video-unscaled" might cause issues with "no-keepaspect"? Have not tested this because I see no reason to use that option, especially when reading manga.
Thanks for writing this script (and for working on mpv in general), it's my main way of reading manga.