VLC backend for Mac OS X

Bug #963955 reported by matysek
22
This bug affects 4 people
Affects Status Importance Assigned to Milestone
OpenLP
Fix Released
High
matysek

Bug Description

VLC backend does not work on Mac. Instructing OpenLP to use vlc backend causes OpenLP to stuck and the application is not responding.

Video playback starts when not trying reset video playback in openly. However the issue is that playback start in an external window and not in openly window.

Getting vlc backend to work is platform specific thing and this needs to be implemented specifically for Mac.

The issue is: Force vlc backend to render video inside a Qt window of OpenLP.

To fi this we will need implement similar code like the following file:
http://code.google.com/p/movie-content-editor/source/browse/trunk/VLCMacVideo.py

Technically speaking wrapping native Mac OS X NSView window into class QtGui.QMacCocoaViewContainer.

Links:

http://groups.google.com/group/wxpython-mac/browse_thread/thread/550a4f93c1e498bd/ec8197dfa78a8201
http://www.videolan.org/developers/vlc/projects/macosx/framework/Sources/VLCVideoView.m
https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/nsview_Class/Reference/NSView.html

Tags: osx vlc

Related branches

Changed in openlp:
status: New → Confirmed
importance: Undecided → Medium
tags: added: osx vlc
Revision history for this message
Brian Meyer (briantmeyer) wrote :
Download full text (4.1 KiB)

Default architecture
on universal vlc
python ./vlc.py /Users/brianmeyerdesign/Movies/Annual_Conference_2012_--_Church_of_the_Brethren_by_Enten_El.mp4
Press q to quit, ? to get help.
[0x1018558f0] main video output error: video output creation failed
[0x100a142f0] main decoder error: failed to create video output
Audio plays

on 32bit vlc
python ./vlc.py /Users/brianmeyerdesign/Movies/Annual_Conference_2012_--_Church_of_the_Brethren_by_Enten_El.mp4
Traceback (most recent call last):
  File "./vlc.py", line 120, in <module>
    dll, plugin_path = find_lib()
  File "./vlc.py", line 107, in find_lib
    dll = ctypes.CDLL(p)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 365, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: dlopen(/Applications/VLC.app/Contents/MacOS/lib/libvlc.dylib, 6): no suitable image found. Did find:
 /Applications/VLC.app/Contents/MacOS/lib/libvlc.dylib: mach-o, but wrong architecture

32bit architecture ( prefix on command line does this )
on 32bit vlc
arch -i386 /opt/local/bin/python ./vlc.py /Users/brianmeyerdesign/Movies/Annual_Conference_2012_--_Church_of_the_Brethren_by_Enten_El.mp4
[0xa4ec98] main video output error: video output creation failed
[0x1800098] main decoder error: failed to create video output
Audio plays

on universal vlc
arch -i386 /opt/local/bin/python ./vlc.py /Users/brianmeyerdesign/Movies/Annual_Conference_2012_--_Church_of_the_Brethren_by_Enten_El.mp4
[0x1803e98] main video output error: video output creation failed
[0x9ece98] main decoder error: failed to create video output
Audio Plays

documents write to set prefs ( no effect, used arch command above instead to test )
defaults write org.openlp.OpenLP.plist Prefer-32-Bit -bool yes
defaults write com.apple.versioner.python Prefer-32-Bit -bool yes

determining architecture commands
Meyer:movie-content-editor-read-only brianmeyerdesign$ which python/opt/local/bin/python
Meyer:movie-content-editor-read-only brianmeyerdesign$ file /opt/local/bin/python/opt/local/bin/python: Mach-O universal binary with 2 architectures
/opt/local/bin/python (for architecture x86_64): Mach-O 64-bit executable x86_64
/opt/local/bin/python (for architecture i386): Mach-O executable i386

$ arch -i386 /opt/local/bin/python -v ./vlc.py /Users/brianmeyerdesign/Movies/Annual_Conference_2012_--_Church_of_the_Brethren_by_Enten_El.mp4

This actually is kind of nice way to start the app, shows messages in terminal, running as 32 bit does not affect the issue
$ arch -i386 /Applications/OpenLP.app/Contents/MacOS/OpenLP
Dynamic session lookup supported but failed: launchd did not provide a socket path, verify that org.freedesktop.dbus-session.plist is loaded!
WARNING: bool Phonon::FactoryPrivate::createBackend() phonon backend plugin could not be loaded
WARNING: bool Phonon::FactoryPrivate::createBackend() phonon backend plugin could not be loaded
WARNING: bool Phonon::FactoryPrivate::createBackend() phonon backend plugin could not be loaded
WARNING: bool Phonon::FactoryPrivate::createBackend() phonon backend plugin could not be loaded
WARNING: bool Phonon::FactoryPrivate::createBackend()...

Read more...

matysek (mzibricky)
Changed in openlp:
assignee: nobody → matysek (mzibricky)
importance: Medium → High
matysek (mzibricky)
Changed in openlp:
milestone: none → 1.9.12
Revision history for this message
matysek (mzibricky) wrote :

I just committed some code to linked branch.

In vlcplayer.py we have to use function .set_nsobject() to tell the vlc backend where the video should be rendered.

However, the video reset() function does not work on OSX. Comment this function makes the playback working in preview.

There are still some remaining issues like:
- control buttons not working
- video on second screen is not displayed
- probably something else

Revision history for this message
Brian Meyer (briantmeyer) wrote :

Did some testing with above changes

Detailed Notes are here
http://pastebin.com/qWEEmTJU

Clearly freezing in the vlc.py stop function ( inside of VLC )

I saw it working with this before, might need to restart to rejigger it.

Works better when started with python, seems to need to be removed when in actual built app from dmg.

Revision history for this message
Brian Meyer (briantmeyer) wrote :

Just found this bit of info reading the comments in the sourcecode for set_nsobject which seems to work....

per the vlc.py, line 2446

def set_nsobject(self, drawable):
Set the NSView handler where the media player should render its video output.
Use the vout called "macosx".

This means it is required to set the vout parameter something like the following in vlcplayer.py on line 124

if sys.platform == "darwin":
            command_line_options += u' --vout=macosx'

Going to do some additional trial and error, but hoping those more skilled in python will find this useful. The issue might be in vlc itself unfortunately.

Revision history for this message
Brian Meyer (briantmeyer) wrote :

I have this working when i build a compiled app or running from python. I am hoping someone else using mac os x can verify this is fixed with these changes.

I made a change to vlc.py which checks if the video is playing, and if not, it does not attempt to stop it, similar to previous fix.

Also did the --vout=macosx per the documentation, but this does not seem to be relevant, but since vlc code says to do it that way, i am leaving that in.

I am assuming that if it's stopped it does not need to be stopped, but not sure if this will affect non-darwin usage, will need to test on other platforms.

Revision history for this message
matysek (mzibricky) wrote :

I tested your branch with running from python. I tested the playback in preview. The playback in preview is the same in your branch as in my branch. What specifically should be fixed with your changes?

The following issues are still present, probably common to all media players on osx:

- with webkit the sound could not be heard in preview
- with vlc the sound is not properly synchronized with video
  - the sound is still played even when pressed buttons stop or pause
- with vlc when 'stop' is pressed and 'play' again - video does not start from beginning
- volume control does not work

Any other issues with video on osx?

Revision history for this message
Brian Meyer (briantmeyer) wrote :

What i was seeing was it would show the previous video when changing videos with your branch for a few seconds. Mainly the "stop" function is the only spot causing the issue and i left it so it can actually run if the video is playing. I tried calling the is_playing function in the vlcplayer.py function, but that did not seem to affect anything.

Hmm yes, audio seems like it's a completely different animal. I'll see what i can figure out there. I am getting it continue regardless of what happens in the video, even when i switch to videos without sound.

Back to the drawing board. I think i need to focus more on what is going on in the vlc side of things. Either that or look at how the handle is referenced.

Changed in openlp:
milestone: 1.9.12 → 2.0
matysek (mzibricky)
Changed in openlp:
status: Confirmed → In Progress
matysek (mzibricky)
Changed in openlp:
status: In Progress → Fix Committed
Tim Bentley (trb143)
Changed in openlp:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.