-
Notifications
You must be signed in to change notification settings - Fork 5
Description
(By single page I mean a vertical page, ie. the opposite of a spread or horizontal page.)
I've been having this weird issue where spreads are sometimes put side by side with other pages, and where single pages take up the whole screen like a spread. I've figured out that this is due to the function store_file_props assuming a page is vertical when width or height are nil (by setting width to 300 and height to 500).
Width and height are taken from the properties track-list/N/demux-w and track-list/N/demux-h, which are not set in certain cases, causing the nil values. One of these cases is when the demuxer is mf, due to demux_mf.c not setting disp_w and disp_h (lines 403-408):
struct mp_codec_params *c = sh->codec;
c->codec = codec;
c->disp_w = 0;
c->disp_h = 0;
c->fps = demuxer->opts->mf_fps;
c->reliable_fps = true;
The confusing part was why mpv is defaulting to the mf demuxer, when the file is a jpeg. In the logs, I found the following tests being performed during the format probing process:
[lavf] Found 'jpeg_pipe' at score=25 size=2048.
[lavf] Found 'jpeg_pipe' at score=25 size=4096.
[lavf] Found 'jpeg_pipe' at score=25 size=8192.
[lavf] Found 'jpeg_pipe' at score=25 size=16384.
...
[lavf] Found 'jpeg_pipe' at score=25 size=10485760.
[lavf] Found 'jpeg_pipe' at score=25 size=10485760.
[lavf] No format found, try lowering probescore or forcing the format.
...
[lavf] Found 'image2' at score=50 size=2048.
[lavf] Format blacklisted.
[demux] Trying demuxer: mf (force-level: unsafe)
I noticed this was previously discussed in #28, but the suggested fix of setting demuxer-lavf-format=jpeg_pipe isn't ideal, because it breaks all formats that aren't jpeg, such as png. Instead, I tried looking at demuxer-lavf-probescore.
The default for demuxer-lavf-probescore is 26, so for some reason the probing process for some jpegs has a score just under what is required. When I lower this option to 25, the jpeg_pipe format is detected, demux-w and demux-h are set. I've just gone through a few files that have been problematic in the past with demuxer-lavf-probescore=20 and they've worked seamlessly, with all the double page problems fixed.
So, a possible solution to this issue is the automatically set demuxer-lavf-probescore to 25 or lower when the manga reader script is running. I'm not sure what other side-effects this could have though. Alternatively, demux_mf.c being patched to properly set disp_w and disp_h would also fix the issue, but that's probably way too complicated.