Baldomo / open-in-mpv

Simple web extension to open videos in mpv
GNU General Public License v3.0
119 stars 7 forks source link

Multiple Issues with Browser Extension on Windows: MPV Path Conflicts, Fullscreen Bug, and PIP Configuration Errors #32

Closed GrainyTV closed 3 months ago

GrainyTV commented 3 months ago

Bug Description

I wanted to check out this browser extension but I came across multiple issues with using it. I did a bit of an investigation on my own and collected what I could for 3 separate bugs. Each of them is detailed below, along with the steps I've taken to resolve them. This was done on Windows platform.

How to Reproduce

Issue 1

I found this one accidentally. I am not a 100% sure if it is a bug, but basically if mpv is installed through the chocolatey package manager, then two separate mpv applications will be visible on the path, namely:

C:\ProgramData\chocolatey\lib\mpv.install\tools\mpv.exe C:\ProgramData\chocolatey\lib\mpv.install\tools\mpv.com

So if we just specify mpv without file extension in the config.yml file under the executable property, it will implicitly call the wrong one with .com and open a terminal window unnecessarily before invoking the actual media.

Issue 2

Now the next one is 100% a valid bug. Basically the built-in button for starting a video in fullscreen would not start the video in fullscreen unless I specified it under the flag_overrides property.

Issue 3

The third issue is related to the picture in picture mode. I copied the default values for my pip property but it failed to open in mpv. From the mpv logs I could see that the whole pip property is passed to mpv as a single value which ruins the command.

Command line options: '--ontop --no-border --autofit=384x216 --geometry=98%:98%' 'https://www.youtube.com/watch?v=OrgpX-_bFqM' '--log-file=mpv.log'

I did not run into this problem with the fullscreen option because it only has one parameter as '--fs'.

Expected Behavior

Fix 1

The documentation should emphasize to use the .exe file extension for the executable property under Windows to call the appropriate mpv application.

Fix 2

This one is caused by a small ambiguity in the codebase. Some parts of the repository like the example and default configuration file show to use a property called fullscreen in one word. While the protocol section shows that it should be full_screen. Now this would only be an issue with the docs but it appears in the source code as well.

common.js - Line 82

params.push("full_screen=1");

options.go - Line 98

o.Fullscreen = u.Query().Get("fullscreen") == "1"

Basically a parameter is added, that is not read and lost during the parsing process.

Fix 3

For this one, the different arguments for pip needed to be separated so it does not think that the whole line is a command line flag. I managed to make it work by splitting the command by whitespaces.

options.go - Line 162 [Original]

ret = append(ret, playerConfig.Pip)

options.go - Line 162 [New]

ret = append(ret, strings.Fields(playerConfig.Pip)...)

Not sure how valid this solution is, but temporarily it fixed the issue from happening for me because each option were passed individually.

Command line options: '--ontop' '--no-border' '--autofit=384x216' '--geometry=98%:98%' 'https://www.youtube.com/watch?v=OrgpX-_bFqM' '--log-file=mpv.log'

Version

latest release v2.2.2

Configuration

players:
  mpv:
    name: mpv
    executable: mpv.exe
    fullscreen: "--fs"
    pip: "--ontop --no-border --autofit=384x216 --geometry=98%:98%"
    enqueue: ""
    new_window: ""
    needs_ipc: false
    flag_overrides: {}

Relevant log output (optional)

[   0.000][d][global] user path: 'mpv.log' -> 'mpv.log'
[   0.006][v][cplayer] mpv 1c9c2f5 Copyright © 2000-2023 mpv/MPlayer/mplayer2 projects
[   0.006][v][cplayer]  built on Dec 10 2023 12:02:37
[   0.006][v][cplayer] libplacebo version: v6.338.0-62-g52314e0-dirty
[   0.006][v][cplayer] FFmpeg version: N-112938-g12e25af7a
[   0.006][v][cplayer] FFmpeg library versions:
[   0.006][v][cplayer]    libavutil       58.32.100
[   0.006][v][cplayer]    libavcodec      60.35.100
[   0.006][v][cplayer]    libavformat     60.18.100
[   0.006][v][cplayer]    libswscale      7.6.100
[   0.006][v][cplayer]    libavfilter     9.14.100
[   0.006][v][cplayer]    libswresample   4.13.100
[   0.006][v][cplayer] 
[   0.006][v][cplayer] Configuration: -Ddebug=true -Db_ndebug=true -Doptimization=3 -Db_lto=true -Db_lto_mode=thin -Dlibmpv=true -Dpdf-build=enabled -Dlua=enabled -Djavascript=enabled -Dsdl2=enabled -Dlibarchive=enabled -Dlibbluray=enabled -Ddvdnav=enabled -Duchardet=enabled -Drubberband=enabled -Dlcms2=enabled -Dopenal=enabled -Dspirv-cross=enabled -Dvulkan=enabled -Dvapoursynth=enabled -Degl-angle=enabled -Dprefix=/__w/mpv-winbuild-cmake/mpv-winbuild-cmake/build_x86_64/x86_64-w64-mingw32 -Dlibdir=/__w/mpv-winbuild-cmake/mpv-winbuild-cmake/build_x86_64/x86_64-w64-mingw32/lib -Ddefault_library=shared -Dprefer_static=True --cross-file=/__w/mpv-winbuild-cmake/mpv-winbuild-cmake/build_x86_64/meson_cross.txt
[   0.006][v][cplayer] List of enabled features: av-channel-layout avif-muxer build-date cplugins cuda-hwaccel cuda-interop d3d-hwaccel d3d11 d3d9-hwaccel debug direct3d dos-paths dvdnav egl-angle egl-angle-win32 egl-helpers ffmpeg ffnvcodec gl gl-dxinterop gl-dxinterop-d3d9 gl-win32 glob glob-win32 gpl iconv javascript jpeg jpegxl lavu-uuid lcms2 libarchive libass libavdevice libbluray libm libplacebo luajit manpage-build noexecstack openal pdf-build rubberband rubberband-3 sdl2 sdl2-audio sdl2-gamepad sdl2-video shaderc spirv-cross threads uchardet vapoursynth vector vulkan vulkan-interop wasapi win32 win32-desktop win32-executable win32-threads zimg zimg-st428 zlib
[   0.006][v][cplayer] Built with NDEBUG.
[   0.006][v][cplayer] Command line options: '--ontop --no-border --autofit=384x216 --geometry=98%:98%' 'https://www.youtube.com/watch?v=OrgpX-_bFqM' '--log-file=mpv.log'
[   0.006][v][cplayer] mpv 1c9c2f5 Copyright © 2000-2023 mpv/MPlayer/mplayer2 projects
[   0.006][v][cplayer]  built on Dec 10 2023 12:02:37
[   0.006][v][cplayer] libplacebo version: v6.338.0-62-g52314e0-dirty
[   0.006][v][cplayer] FFmpeg version: N-112938-g12e25af7a
[   0.006][v][cplayer] FFmpeg library versions:
[   0.006][v][cplayer]    libavutil       58.32.100
[   0.006][v][cplayer]    libavcodec      60.35.100
[   0.006][v][cplayer]    libavformat     60.18.100
[   0.006][v][cplayer]    libswscale      7.6.100
[   0.006][v][cplayer]    libavfilter     9.14.100
[   0.006][v][cplayer]    libswresample   4.13.100
[   0.006][v][cplayer] 
[   0.006][v][cplayer] Configuration: -Ddebug=true -Db_ndebug=true -Doptimization=3 -Db_lto=true -Db_lto_mode=thin -Dlibmpv=true -Dpdf-build=enabled -Dlua=enabled -Djavascript=enabled -Dsdl2=enabled -Dlibarchive=enabled -Dlibbluray=enabled -Ddvdnav=enabled -Duchardet=enabled -Drubberband=enabled -Dlcms2=enabled -Dopenal=enabled -Dspirv-cross=enabled -Dvulkan=enabled -Dvapoursynth=enabled -Degl-angle=enabled -Dprefix=/__w/mpv-winbuild-cmake/mpv-winbuild-cmake/build_x86_64/x86_64-w64-mingw32 -Dlibdir=/__w/mpv-winbuild-cmake/mpv-winbuild-cmake/build_x86_64/x86_64-w64-mingw32/lib -Ddefault_library=shared -Dprefer_static=True --cross-file=/__w/mpv-winbuild-cmake/mpv-winbuild-cmake/build_x86_64/meson_cross.txt
[   0.006][v][cplayer] List of enabled features: av-channel-layout avif-muxer build-date cplugins cuda-hwaccel cuda-interop d3d-hwaccel d3d11 d3d9-hwaccel debug direct3d dos-paths dvdnav egl-angle egl-angle-win32 egl-helpers ffmpeg ffnvcodec gl gl-dxinterop gl-dxinterop-d3d9 gl-win32 glob glob-win32 gpl iconv javascript jpeg jpegxl lavu-uuid lcms2 libarchive libass libavdevice libbluray libm libplacebo luajit manpage-build noexecstack openal pdf-build rubberband rubberband-3 sdl2 sdl2-audio sdl2-gamepad sdl2-video shaderc spirv-cross threads uchardet vapoursynth vector vulkan vulkan-interop wasapi win32 win32-desktop win32-executable win32-threads zimg zimg-st428 zlib
[   0.006][v][cplayer] Built with NDEBUG.
[   0.007][d][global] home path: '' -> 'C:\Users\Personal\AppData\Roaming/mpv'
[   0.007][d][global] user path: '~~home/' -> 'C:\Users\Personal\AppData\Roaming/mpv'
[   0.008][d][global] user path: '~~old_home/' -> ''
[   0.008][d][global] config path: 'encoding-profiles.conf' -/-> 'C:\Users\Personal\AppData\Roaming/mpv/encoding-profiles.conf'
[   0.008][d][global] config path: 'encoding-profiles.conf' -/-> 'C:/ProgramData/chocolatey/lib/mpv.install/tools/encoding-profiles.conf'
[   0.008][d][global] config path: 'encoding-profiles.conf' -/-> 'C:/ProgramData/chocolatey/lib/mpv.install/tools/mpv/encoding-profiles.conf'
[   0.008][d][global] config path: 'mpv.conf' -/-> 'C:\Users\Personal\AppData\Roaming/mpv/mpv.conf'
[   0.008][d][global] config path: 'config' -/-> 'C:\Users\Personal\AppData\Roaming/mpv/config'
[   0.008][d][global] config path: 'mpv.conf' -/-> 'C:/ProgramData/chocolatey/lib/mpv.install/tools/mpv.conf'
[   0.008][d][global] config path: 'config' -/-> 'C:/ProgramData/chocolatey/lib/mpv.install/tools/config'
[   0.008][d][global] config path: 'mpv.conf' -/-> 'C:/ProgramData/chocolatey/lib/mpv.install/tools/mpv/mpv.conf'
[   0.008][d][global] config path: 'config' -/-> 'C:/ProgramData/chocolatey/lib/mpv.install/tools/mpv/config'
[   0.008][e][cplayer] Error parsing option ontop --no-border --autofit (option not found)
[   0.008][f][cplayer] Setting commandline option --ontop --no-border --autofit=384x216 --geometry=98%:98% failed.
[   0.008][i][cplayer] Exiting... (Fatal error)

What browsers are you seeing the problem on? (optional)

Chromium-based (Brave, Chrome, etc.)

Checklist:

Baldomo commented 3 months ago

Nice catches! I will investigate and roll the fixes ASAP

GrainyTV commented 3 months ago

I tried out the new 2.3.0 Windows version of the executable, and it looks like all the issues I reported have been resolved. I'm going to go ahead and close this ticket now.