jaseg / python-mpv

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

python not launching mpv #36

Closed kirkegaard closed 6 years ago

kirkegaard commented 7 years ago

I was trying one of your examples but the player never seemed to launch. I tried adding some debugging code as you advised in another issue but i cant seem to figure out why its not launching the player. This is the code im using and the files are just regular h264 files. Im on osx 10.11 and using python 3.6.1 and mpv 0.25.0. The library seems to find the dylib file just fine /usr/local/lib/libmpv.dylib

#!/usr/bin/env python3
import mpv

player = mpv.MPV(log_handler=print)
player.set_loglevel('debug')

player.playlist_append('/Users/christian/Movies/watch/file01.mp4')
player.playlist_append('/Users/christian/Movies/watch/file02.mp4')

player.playlist_pos = 0

while True:
    print(player.playlist)
    player.wait_for_playback()

Log: https://pastebin.com/raw/U5ExvigH

jaseg commented 7 years ago

Does the first file play using mpv -vo opengl file01.mp4? The log indicates the mpv core is correctly loading the first file and the demuxer is working as it should, but your log stops right at the point where normally the video output driver would start to do its thing. Does the program just hang at this point?

Perhaps try running the program again with the loglevel set to 'trace' to coax mpv into producing some more information on where the problem might be.

jaseg commented 7 years ago

BTW, you can also try playing the test file from this repo, which is a webm/vp8-encoded video file to make sure it's not a codec problem.

kirkegaard commented 7 years ago

mpv -vo opengl file01.mp4 worked just fine and yes the log ends where the the scripts just hangs at wait_for_playback().

This is the output if i play the video using mpv:

Playing: file01.mp4
 (+) Video --vid=1 (*) (h264 1280x720 23.976fps)
 (+) Audio --aid=1 --alang=und (*) (aac 2ch 44100Hz)
AO: [coreaudio] 44100Hz stereo 2ch floatp
VO: [opengl] 1280x720 yuv420p
AV: 00:00:09 / 00:04:02 (3%) A-V:  0.000

I tried with the test file but the same thing happened. I tried the trace log as well but i dont see any thing that would indicate whats going on.

Heres the log. I left all the duplicated lines in there this time: https://gist.githubusercontent.com/kirkegaard/cdfbdce956245c349d373050bdce5171/raw/0453ceb2f972338666d69fc331e6c10df596f213/mpv.log

kirkegaard commented 7 years ago

Holy crap, tried logging the test file. Its way smaller! Still same output though. https://gist.githubusercontent.com/kirkegaard/c62edffc7e71b55399c253202d7414c9/raw/4542692cfb9d9cd6c012fe925bf611cacf39c828/mpv.log

jaseg commented 7 years ago

Hmm. This looks like some vo driver problem. There is a couple of things that you can try now. (Sorry, I can't reproduce your problem since I don't have any macs available)

jaseg commented 7 years ago

Any news? If you still need help, just reopen this issue.

kirkegaard commented 7 years ago

Hey sorry, i sort of got away from this. I've testet the same code on linux at it works perfectly. It seems like its having trouble talking to the libmpv that ships with brew on osx. Im having trouble using gdb for debugging since im using pyenv. I have to figure out fixing that first :) But ill let you know when i figure something out! Thanks!

jaseg commented 7 years ago

With pyenv something along the lines of gdb --args $(which python3) test_script.py should work.

Shu-Ji commented 6 years ago

I have the same problem. On windows and x11, create multiple window is easy, but not osx. Maybe we should launch a window before we "inject" mpv video, so we can use wxpython/pyqt5 and so on. I make it work after meeting this: https://github.com/coryo/python-mpv . See the demo of pyqt5.

the main snippet(https://github.com/coryo/python-mpv/blob/master/demo/pyqt5.py#L76-L83):

        self.mpv_container = QWidget(self)
        wid = int(self.mpv_container.winId())
        self.mpv = Mpv(parent=self,
                       wid=wid,
                       log_handler=mpv_log.debug,
                       log_level=mpv.LogLevel.INFO,
                       input_cursor=False,
                       hwdec='auto',
                       observe=['track-list', 'playback-time', 'duration'])
jaseg commented 6 years ago

I'm migrating this "unknown hang on OSX" issue to #61