vlc mac python binding no video output

2020-06-23 06:10发布

问题:

I am using vlc python binding to play a video. Then I got these errors:

[0x3d0c58] main window error: corrupt module: /Applications/VLC.app/Contents/MacOS/plugins/libmacosx_plugin.dylib
[0x3c9af8] vout_macosx vout display error: No drawable-nsobject nor vout_window_t found, passing over.
[0x3178a98] main video output error: video output creation failed
[0xa48c98] main decoder error: failed to create video output

The video won't show. However audio is ok, I can hear the audio without problem. And I can also call all other python vlc functions like play(), pause(), ... without problem. Just no video.

It's VLC 2.0.8 32bit, OSX 10.8.4 64bit, and python is 3.3.2 32bit. Using VLC directly has no problem playing any video. This only happens when I use python command line.

However I did the same thing in windows 7, everything works perfectly. So is this a mac only problem?

I download my python vlc bindings from: http://liris.cnrs.fr/advene/download/python-ctypes/

回答1:

The mentioned solution (use -I macosx) works because it launches an interface, which provides a NSObject (macosx window handle) to the vout_macosx module. When launching from libvlc, no such interface/window is present by default. It works on other platforms because the video output modules know how to create their own windows, but it is not the case on macosx.

You have 2 options:

  • create a window in macosx (using either the native cocoa API or a widget lib like Qt), and pass its reference through the set_nsobject() method

  • install the XQuartz X11 server and use the x11 video output module (not very satisfying nor efficient, but it works)



回答2:

Just put some code like this just before you call player.play(). As mentioned by Oliver's comment you need to create a Window and pass it to VLC.

I haven't tested on any other platforms yet, but it sounds like this isn't needed on other platforms, although the code on github I used for inspiration seems to have system-specific code.

    if sys.platform == "darwin":
        from PyQt4 import QtCore
        from PyQt4 import QtGui
        import sys

        vlcApp =QtGui.QApplication(sys.argv)
        vlcWidget = QtGui.QFrame()
        vlcWidget.resize(700,700)
        vlcWidget.show()
        player.set_nsobject(vlcWidget.winId())

    player.play()