Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mpv with gpu-next doesn't work with ghostty terminal #15642

Closed
6 tasks done
msridhar opened this issue Jan 4, 2025 · 7 comments
Closed
6 tasks done

mpv with gpu-next doesn't work with ghostty terminal #15642

msridhar opened this issue Jan 4, 2025 · 7 comments
Labels

Comments

@msridhar
Copy link

msridhar commented Jan 4, 2025

mpv Information

mpv 0.39.0 Copyright © 2000-2024 mpv/MPlayer/mplayer2 projects
libplacebo version: v7.349.0
FFmpeg version: 7.1
FFmpeg library versions:
   libavcodec      61.19.100
   libavdevice     61.3.100
   libavfilter     10.4.100
   libavformat     61.7.100
   libavutil       59.39.100
   libswresample   5.3.100
   libswscale      8.3.100

Other Information

- macOS version: macOS 15.2 (24C101)
- Source of mpv: Homebrew
- Latest known working version: unknown
- Issue started after the following happened: switched to [ghostty](https://ghostty.org)

Reproduction Steps

I'm on an M1 Pro 2021 MB Pro, and I've installed mpv 0.39.0_1 from Homebrew. When I try to play any video with mpv using the --vo=gpu-next option from ghostty, I don't see any video. E.g., if I download this file and try to play it here's what I see at the console:

$ mpv --vo=gpu-next sample-5s.mp4
● Video  --vid=1               (h264 1920x1080 30 fps) [default]
● Audio  --aid=1  --alang=eng  (aac 2ch 44100 Hz 128 kbps) [default]
[vo/gpu-next] Failed initializing any suitable GPU context!
Error opening/initializing the selected video_out (--vo) device.
Video: no video
AO: [coreaudio] 44100Hz stereo 2ch floatp

I hear audio, but see no video. If I don't pass the --vo=gpu-next option and just run mpv sample-5s.mp4, the video plays fine from ghostty. And, from iTerm2 and Terminal, mpv --vo=gpu-next sample-5s.mp4 succeeds in playing the video.

I also reported this under Ghostty Discussions but haven't yet seen a response there.

Expected Behavior

Video to be visible

Actual Behavior

Video was not visible (audio still worked)

Log File

output.txt

Sample Files

sample-5s.mp4.zip

I carefully read all instruction and confirm that I did the following:

  • I tested with the latest mpv version to validate that the issue is not already fixed.
  • I provided all required information including system and mpv version.
  • I produced the log file with the exact same set of files, parameters, and conditions used in "Reproduction Steps", with the addition of --log-file=output.txt.
  • I produced the log file while the behaviors described in "Actual Behavior" were actively observed.
  • I attached the full, untruncated log file.
  • I attached the backtrace in the case of a crash.
@msridhar msridhar added the os:mac label Jan 4, 2025
@llyyr
Copy link
Contributor

llyyr commented Jan 4, 2025

You're most likely running a different shell environment across the two terminals, leading mpv to not find any usable GPU drivers.

Run env in both terminals and compare their outputs. This isn't a mpv or ghosttty bug.

@msridhar
Copy link
Author

msridhar commented Jan 4, 2025

Thanks for the tip! I'm looking at the differences in the env output and nothing is jumping out at me. Is there a particular environment variable that would impact the GPU driver lookup? I see differences in TERM and PATH, but in Ghostty setting those env vars to the identical value observed in iTerm2 doesn't fix the problem.

My other uneducated guess was that Ghostty's GPU acceleration might be impacting things, but maybe that's way off.

@m154k1
Copy link
Contributor

m154k1 commented Jan 4, 2025

It's because Homebrew's molten-vk package installs ICD json file into share and vulkan-loader package uses FALLBACK_DATA_DIRS for ICD discovery.
Ghostty exports XDG_DATA_DIRS which means FALLBACK_DATA_DIRS will be ignored.

This leads to situation where no vulkan driver is discoverable. I've managed to work around this by installing ICD json into etc and using SYSCONFDIR for my personal build scripts: m154k1/mpv-build-macOS@5ffedcd
I guess Homebrew should do something similar.

@llyyr
Copy link
Contributor

llyyr commented Jan 4, 2025

In that case, simply setting VK_ICD_FILENAMES should work too no?

export VK_ICD_FILENAMES="/path/to/icd.json" before starting mpv

@msridhar
Copy link
Author

msridhar commented Jan 4, 2025

Awesome! I've confirmed that this command works in Ghostty:

VK_ICD_FILENAMES="/opt/homebrew/Cellar/molten-vk/1.2.11/share/vulkan/icd.d/MoltenVK_icd.json" mpv --vo=gpu-next sample-5s.mp4

@m154k1 do you think it would be appropriate to report this issue on Homebrew/homebrew-core then?

@m154k1
Copy link
Contributor

m154k1 commented Jan 4, 2025

In that case, simply setting VK_ICD_FILENAMES should work too no?

That's right. However, note that VK_ICD_FILENAMES is deprecated so it's better to use VK_DRIVER_FILES or VK_ADD_DRIVER_FILES (see this for more info).

@m154k1 do you think it would be appropriate to report this issue on Homebrew/homebrew-core then?

Yeah, something like "molten-vk package should install ICD json file to etc instead of share".

@msridhar
Copy link
Author

msridhar commented Jan 4, 2025

Reported as Homebrew/homebrew-core#203233. I'll go ahead and close this issue. Thanks so much for the help!

@msridhar msridhar closed this as completed Jan 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants