Dudemanguy / mpv-manga-reader

Manga reading script for mpv
GNU General Public License v3.0
119 stars 4 forks source link

Double page mode only works for first page #15

Closed neckothy closed 2 years ago

neckothy commented 2 years ago

As the title says, activating double page mode typically only works for the first image. Sometimes that doesn't work properly either. No errors to show. I can see that it correctly adds the 2nd video track, but only the 1st video track is active. When double page mode is working properly on the first page, both video tracks are marked as active. I get this same issue with no other scripts added and default mpv conf. Any ideas?

mpv 0.34.1

Dudemanguy commented 2 years ago

There's some logic errors in the double page mode somewhere. I've occasionally gotten it in some scans. I've been too lazy to dig through and find the problem, but I should probably fix it.

Edit: although it should certainly work for more than just the first page. That sounds pretty messed up.

neckothy commented 2 years ago

Ok. To clarify I am trying this with official English digitals. They almost always have the same height for all pages. Here are some excerpts from my logs which I believe are related. As you can see it adds the 2nd video track correctly, but does not stack them. The 2nd track remains inactive. The 1px difference in height in the "working" page, vs. no difference in the "broken" page, is just an unlucky choice of logs from me. I checked other books without the 1px height difference and they functioned the same. I also tried making 4 images (p001: 1080x1919, p002-004: 1080x1920) but double page mode worked as intended for those images. I then tried unzipping the archives I was originally testing on, but that seemed to make no difference.

Let me know if there's any other troubleshooting steps you'd like me to try, or if you need more verbose logs. I just cut out sections that were largely unchanged between "working" and "not working" pages.

after activating double page mode on cover

[ 6.442][v][cplayer] Opening done: archive://The Voynich Hotel v01 (2018) (Digital) (danke-Empire).cbz|/The Voynich Hotel - c001 (v01) - p000 [Cover] [dig] [Seven Seas] [danke-Empire] {HQ}.jpg [ ... ] [ 6.442][d][cplayer] Run command: video-add, flags=64, args=[url="archive://The Voynich Hotel v01 (2018) (Digital) (danke-Empire).cbz|/The Voynich Hotel - c001 (v01) - p001 [dig] [Seven Seas] [danke-Empire] {HQ}.jpg", flags="auto", title="", lang="", albumart="no"] [ ... ] [ 6.452][v][cplayer] Set property: lavfi-complex="[vid2] scale=2144x3056:flags=lanczos [vid2_scale]; [vid2_scale] [vid1] hstack [vo]" -> 1 [ 6.452][v][cplayer] Set property: force-media-title="The Voynich Hotel - c001 (v01) - p000 [Cover] [dig] [Seven Seas] [danke-Empire] {HQ}-The Voynich Hotel - c001 (v01) - p001 [dig] [Seven Seas] [danke-Empire] {HQ}.jpg" -> 1 [ 6.453][d][ffmpeg] Parsed_scale_0: w:2144 h:3056 flags:'lanczos' interl:0 [ ... ] [ 6.454][v][lavf] select track 0 [ 6.454][v][lavf] select track 0 [ 6.454][i][cplayer] (+) Video --vid=1 (mjpeg 2144x3056 1.000fps) [ 6.454][i][cplayer] (+) Video --vid=2 'The Voynich Hotel - c001 (v01) - p001 [dig] [Seven Seas] [danke-Empire] {HQ}.jpg' (mjpeg 2145x3056 1.000fps) (external) [ 6.454][v][cplayer] Starting playback...

after turning page

[ 10.676][v][cplayer] Opening done: archive://The Voynich Hotel v01 (2018) (Digital) (danke-Empire).cbz|/The Voynich Hotel - c001 (v01) - p002 [ToC] [dig] [Seven Seas] [danke-Empire] {HQ}.jpg [ ... ] [ 10.676][d][cplayer] Run command: video-add, flags=64, args=[url="archive://The Voynich Hotel v01 (2018) (Digital) (danke-Empire).cbz|/The Voynich Hotel - c001 (v01) - p003 [dig] [Seven Seas] [danke-Empire] {HQ}.jpg", flags="auto", title="", lang="", albumart="no"] [ ... ] [ 10.686][v][cplayer] Set property: lavfi-complex="" -> 1 [ 10.686][v][cplayer] Set property: force-media-title="" -> 1 [ 10.686][v][lavf] select track 0 [ 10.686][i][cplayer] (+) Video --vid=1 (mjpeg 2145x3056 1.000fps) [ 10.686][i][cplayer] Video --vid=2 'The Voynich Hotel - c001 (v01) - p003 [dig] [Seven Seas] [danke-Empire] {HQ}.jpg' (mjpeg 2145x3056 1.000fps) (external) [ ... ] [ 10.687][v][cplayer] Starting playback...

edit: I just tried renaming the pages in these books to simple names (p001.jpg, etc,) which also made no difference.

edit2: added some simple prints in check_aspect_ratio() and found that it seems to be returning weird display_width and display_height after turning the page.

working

[manga_reader] detected aspect ratio: [manga_reader] 3840 2160 [manga_reader] 1.7777777777778 [manga_reader] good aspect ratio: [manga_reader] 4289 3056 [manga_reader] 1.4034685863874

not working

[manga_reader] detected aspect ratio: [manga_reader] 1920 3240 [manga_reader] 0.59259259259259 [manga_reader] not good aspect ratio: [manga_reader] 4290 3056 [manga_reader] 1.4037958115183

So I was able to fix this by using 1920x1080 as the dimensions. Maybe something with my odd monitor setup? Though I'm not sure why it would work for the initial page but change after switching pages.

A bit related, the script seems to want to read opts.monitor_width and opts.monitor_height, but trying to set those in script-opts gives me an unknown key error. Also, it would only fall back to these configured ones in the event mpv returns nil for display_width and display_height. Maybe this should be user configurable (overriding whatever value mpv detects)? Anyway, for now I've just forced the dimensions within the script and everything is working smoothly.

Dudemanguy commented 2 years ago

Ah, so returning incorrect monitor widths/heights would certainly explain it. I'm not sure why on earth this would randomly change though. Are you using X11 or Wayland? As for opts.monitor_width/monitor_height, that was an old mechanism that I removed but apparently I forgot to ax that one line.

neckothy commented 2 years ago

X11, and probably a fairly uncommon setup with 2 1080 monitors below a 4k tv, making my full display size 3840x3240. I only really read on a single 1080 display though. I noticed for the first page it seems to return 4k (3840x2160,) while after turning the page it returns the width of the display I'm reading on but the combined height (1920x3240.) I don't know much about that end of things so won't bother guessing why.

Dudemanguy commented 2 years ago

Glancing again at mpv's x11 code for this, I think it's just wrong (I should probably fix it considering I was the one who wrote it...). mpv-manga-reader could handle this better as well.

Dudemanguy commented 2 years ago

@neckothy: I think https://github.com/mpv-player/mpv/pull/10513 should fix this. Could you test it out on your setup?

neckothy commented 2 years ago

That seems to have fixed my issue. Thanks.