jaseg / python-mpv

Python interface to the awesome mpv media player
https://git.jaseg.de/python-mpv.git
Other
555 stars 69 forks source link

Player not opening in MacOS #253

Open Aniruddh-J opened 1 year ago

Aniruddh-J commented 1 year ago

Hello,

I installed mpv using Homebrew and tested if it is working with the command mpv {filename} but it doesn't work using this Python library:

player.play(video_file)
player.wait_until_playing() // or player.wait_for_playerback()
jaseg commented 1 year ago

I cannot help you with that since I don't have an Apple device to test this on. Here's a few suggestions of what you could try:

  1. Double-check that the mpv version of your command-line mpv binary and of libmpv are the same. You can get the version of the command-line binary by running mpv --version (first line of output), and the version of libmpv by running import mpv; player = mpv.MPV(); print(player.mpv_version).
  2. Make python-mpv output debug log messages, and check for any errors. You can do that by setting log_level and registering a log handler like this:
    def my_log(loglevel, component, message):
    print('[{}] {}: {}'.format(loglevel, component, message.strip()))
    player = mpv.MPV(log_handler=my_log, loglevel='debug')
  3. Try changing the video output (--vo option in the command-line utility, vo parameter to mpv.MPV(...))
  4. Make sure you don't have to set some environment variable such as $DISPLAY on your shell to get libmpv to find your display output
frankchau93 commented 1 year ago

I'm running into the same issue. The debug logs look like it's running but nothing shows. Just a python icon that pops up but no player.

EngineersNeedArt commented 1 month ago

Also on MacOS (Apple Silicon). Wilder still, I hear the video playing back, do not see the window/image.

Both versions of mpv match.

From debug-level log:

[error] vo/gpu-next/vulkan: Failed to initialize macvk context, no NSApplication initialized.
[fatal] cplayer: Error opening/initializing the selected video_out (--vo) device.
EngineersNeedArt commented 1 month ago

Since command-line on MacOS works, ran in verbose mode. I see:

[vo/gpu/libplacebo] Failed creating instance: VK_ERROR_EXTENSION_NOT_PRESENT
[vo/gpu/libplacebo] Failed initializing vulkan instance
[vo/gpu/vulkan] Initializing GPU context 'macvk'
[vo/gpu/libplacebo] Initialized libplacebo v7.349.0 (API v349)
[vo/gpu/libplacebo] Creating vulkan instance with extensions:

Compare this to logging from Python on same OS:

[v] vo/gpu/libplacebo: Failed creating instance: VK_ERROR_EXTENSION_NOT_PRESENT
[v] vo/gpu/libplacebo: Failed initializing vulkan instance
[v] vo/gpu/vulkan: Initializing GPU context 'macvk'
[error] vo/gpu/vulkan: Failed to initialize macvk context, no NSApplication initialized.
[v] vo/gpu-next: Probing for best GPU context.

Obviously they diverge in the last two logs.

Maybe there's a clue in the above as to how the C/L handles video playback more robustly on MacOS.