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

python not launching mpv #36

Closed
kirkegaard opened this issue Jul 11, 2017 · 10 comments
Closed

python not launching mpv #36

kirkegaard opened this issue Jul 11, 2017 · 10 comments

Comments

@kirkegaard
Copy link

kirkegaard commented Jul 11, 2017

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
Copy link
Owner

jaseg commented Jul 11, 2017

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
Copy link
Owner

jaseg commented Jul 11, 2017

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
Copy link
Author

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
Copy link
Author

kirkegaard commented Jul 11, 2017

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
Copy link
Owner

jaseg commented Jul 12, 2017

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)

  • Make sure both libmpv and mpv on your system are reasonably recent (less than a year old or so). They might be coming from different packages (or whatever you're using on mac). You can get libmpv's version using python3 -c 'import mpv; print(mpv._mpv_client_api_version())'
  • Try another vo. I don't know which vos are available on mac, but you can have a look at this list. You can set the vo using something like player['vo'] = 'opengl'
  • Spin up a debugger and have a look where exactly mpv hangs. In case it is a vo problem (and not something I fucked up) and your mpv is fairly recent, filing an upstream bug report might be appropriate. Using gdb you can get a first glance at things:
    • Run gdb --args python test_script.py
    • Type r [enter] to make gdb start the program
    • Wait until it hangs
    • Press [ctrl] c in the terminal to break into gdb's shell
    • List running threads with info threads [enter]
    • Switch to the thread named mpv/playback using thread <its thread Id from the list> [enter]
    • Produce a backtrace using bt [enter]
    • Repeat for the thread called mpv/vo
      If you post the gdb log here I can maybe make a guess.

@jaseg
Copy link
Owner

jaseg commented Aug 2, 2017

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

@jaseg jaseg closed this as completed Aug 2, 2017
@kirkegaard
Copy link
Author

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
Copy link
Owner

jaseg commented Aug 4, 2017

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

@Shu-Ji
Copy link

Shu-Ji commented Nov 25, 2017

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
Copy link
Owner

jaseg commented Dec 25, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants