Skip to content

Hardware decoding with libmpv #300

@shibotto

Description

@shibotto

I'm currently trying to use this inside a GTK+ 3 window on X11, but I chose the OpenGL approach because I want it to work on Wayland as well. This means that to embed it I need to use vo=libmpv, which works fine, although I'm having a hard time making vaapi work for hardware decoding. For reference, I'm doing a mix of your gist example and https://github.com/trin94/python-mpv-gtk4.

Digging around libmpv and OpenGL, I found https://www.ccoderun.ca/programming/doxygen/mpv/structmpv__opengl__init__params.html, which says it is fully supported, but needs to be set up. So I digged more and I found mpvqt (used by Haruna) and celluloid which seem to do this. The problem is that they are in C++ and C respectively and I'm not sure how to translate it to Python.

I kinda figured that I need to pass either "x11_display=" or "wl_display=" to MpvRenderContext() (mainly because it doesn't complain about them, to be honest), but then I'm not sure what the "display" argument should be. Trying to copy Celluloid for GTK, I arrived at something like

display = GdkDisplay.get_default()
x11_display = display.get_xdisplay()

but of course I can't just pass that and I'm not so versed in C to really understand what's going on (is it expecting a pointer?). Do you think you can help me out?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions