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

Stuck in gpu initialize #89

Open
OldTiger opened this issue Aug 5, 2019 · 2 comments
Open

Stuck in gpu initialize #89

OldTiger opened this issue Aug 5, 2019 · 2 comments

Comments

@OldTiger
Copy link

OldTiger commented Aug 5, 2019

Python:3.7
OS:mac 10.14.5

import mpv
def my_log(loglevel, component, message):
    print('[{}] {}: {}'.format(loglevel, component, message))

player = mpv.MPV(log_handler=my_log, ytdl=True, loglevel='debug')

player.play('https://www.bilibili.com/video/av38334623?spm_id_from=333.45.b_63696e657068696c655f63696e656369736d.5.')
player.wait_for_playback()

print('success')

Log is

[v] cplayer: Set property: options/vo="gpu" -> 1
[debug] cplayer: Run command: loadfile, flags=0, args=[https://www.bilibili.com/video/av38334623?spm_id_from=333.45.b_63696e657068696c655f63696e656369736d.5., replace, ]
[debug] stats: loading @stats.lua
[debug] ytdl_hook: loading @ytdl_hook.lua
[debug] ytdl_hook: reading options for ytdl_hook
[v] ytdl_hook: script-opts/ytdl_hook.conf not found.
[v] ytdl_hook: lua-settings/ytdl_hook.conf not found.
[debug] stats: reading options for stats
[v] stats: script-opts/stats.conf not found.
[v] stats: lua-settings/stats.conf not found.
[debug] cplayer: Run command: define-section, flags=0, args=[input_stats, i script-binding stats/display-stats
[debug] cplayer: , default]
[debug] cplayer: Run command: enable-section, flags=0, args=[input_stats, allow-hide-cursor+allow-vo-dragging]
[debug] cplayer: Run command: define-section, flags=0, args=[input_forced_stats, , force]
[debug] cplayer: Run command: enable-section, flags=0, args=[input_forced_stats, allow-hide-cursor+allow-vo-dragging]
[debug] cplayer: Run command: define-section, flags=0, args=[input_stats, I script-binding stats/display-stats-toggle
[debug] cplayer: i script-binding stats/display-stats
[debug] cplayer: , default]
[debug] cplayer: Run command: enable-section, flags=0, args=[input_stats, allow-hide-cursor+allow-vo-dragging]
[debug] cplayer: Run command: define-section, flags=0, args=[input_forced_stats, , force]
[debug] cplayer: Run command: enable-section, flags=0, args=[input_forced_stats, allow-hide-cursor+allow-vo-dragging]
[debug] cplayer: Run command: define-section, flags=0, args=[input_stats, i script-binding stats/display-stats
[debug] cplayer: I script-binding stats/display-stats-toggle
[debug] cplayer: , default]
[debug] cplayer: Run command: enable-section, flags=0, args=[input_stats, allow-hide-cursor+allow-vo-dragging]
[debug] cplayer: Run command: define-section, flags=0, args=[input_forced_stats, , force]
[debug] cplayer: Run command: enable-section, flags=0, args=[input_forced_stats, allow-hide-cursor+allow-vo-dragging]
[debug] cplayer: Run command: define-section, flags=0, args=[input_stats, i script-binding stats/display-stats
[debug] cplayer: I script-binding stats/display-stats-toggle
[debug] cplayer: , default]
[debug] cplayer: Run command: enable-section, flags=0, args=[input_stats, allow-hide-cursor+allow-vo-dragging]
[debug] cplayer: Run command: define-section, flags=0, args=[input_forced_stats, , force]
[debug] cplayer: Run command: enable-section, flags=0, args=[input_forced_stats, allow-hide-cursor+allow-vo-dragging]
[v] cplayer: Done loading scripts.
[debug] global: config path: 'watch_later' -> '-'
[debug] global: config path: 'watch_later' -> '-'
[info] cplayer: Playing: https://www.bilibili.com/video/av38334623?spm_id_from=333.45.b_63696e657068696c655f63696e656369736d.5.
[v] cplayer: Running hook: ytdl_hook/on_load
[v] ytdl_hook: ytdl:// hook
[v] ytdl_hook: not a ytdl:// url
[v] ffmpeg: Opening https://www.bilibili.com/video/av38334623?spm_id_from=333.45.b_63696e657068696c655f63696e656369736d.5.
[debug] ffmpeg: tcp: Starting connection attempt to 164.52.28.62 port 443
[debug] ffmpeg: tcp: Successfully connected to 164.52.28.62 port 443
[warn] ffmpeg: https: HTTP error 403 Forbidden
[error] stream: Failed to open https://www.bilibili.com/video/av38334623?spm_id_from=333.45.b_63696e657068696c655f63696e656369736d.5..
[v] cplayer: Opening failed or was aborted: https://www.bilibili.com/video/av38334623?spm_id_from=333.45.b_63696e657068696c655f63696e656369736d.5.
[v] cplayer: Running hook: ytdl_hook/on_load_fail
[v] ytdl_hook: full hook
[debug] ytdl_hook: Running: youtube-dl --no-warnings -J --flat-playlist --sub-format ass/srt/best --format bestvideo+bestaudio/best --all-subs --no-playlist -- https://www.bilibili.com/video/av38334623?spm_id_from=333.45.b_63696e657068696c655f63696e656369736d.5.
[v] ytdl_hook: youtube-dl succeeded!
[debug] ytdl_hook: ytdl parsing took 0.00078999999999996 seconds
[debug] ytdl_hook: No fragments to join into EDL
[v] cplayer: Set property: file-local-options/user-agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3551.0 Safari/537.36" -> 1
[v] cplayer: Set property: file-local-options/http-header-fields=["Referer: https://www.bilibili.com/video/av38334623?spm_id_from=333.45.b_63696e657068696c655f63696e656369736d.5."] -> 1
[debug] ytdl_hook: streamurl: http://upos-hz-mirrorwcsu.acgvideo.com/upgcxcode/30/00/67380030/67380030-1-64.flv?e=ig8euxZM2rNcNbKHhwdVhoMMnWdVhwdEto8g5X10ugNcXBlqNxHxNEVE5XREto8KqJZHUa6m5J0SqE85tZvEuENvNC8xNEVE9EKE9IMvXBvE2ENvNCImNEVEK9GVqJIwqa80WXIekXRE9IMvXBvEuENvNCImNEVEua6m2jIxux0CkF6s2JZv5x0DQJZY2F8SkXKE9IB5QK==&deadline=1564995413&gen=playurl&nbs=1&oi=628660170&os=wcsu&platform=pc&trid=537dfd13138e448ba7a4f6e6e87b9ac6&uipk=5&upsig=0a8c00050927b912d4ec6e1aada51434&uparams=e,deadline,gen,nbs,oi,os,platform,trid,uipk&mid=0
[v] cplayer: Set property: stream-open-filename="http://upos-hz-mirrorwcsu.acgvideo.com/upgcxcode/30/00/67380030/67380030-1-64.flv?e=ig8euxZM2rNcNbKHhwdVhoMMnWdVhwdEto8g5X10ugNcXBlqNxHxNEVE5XREto8KqJZHUa6m5J0SqE85tZvEuENvNC8xNEVE9EKE9IMvXBvE2ENvNCImNEVEK9GVqJIwqa80WXIekXRE9IMvXBvEuENvNCImNEVEua6m2jIxux0CkF6s2JZv5x0DQJZY2F8SkXKE9IB5QK==&deadline=1564995413&gen=playurl&nbs=1&oi=628660170&os=wcsu&platform=pc&trid=537dfd13138e448ba7a4f6e6e87b9ac6&uipk=5&upsig=0a8c00050927b912d4ec6e1aada51434&uparams=e,deadline,gen,nbs,oi,os,platform,trid,uipk&mid=0" -> 1
[v] cplayer: Set property: file-local-options/force-media-title="【木鱼微剧场】诺兰作品《星际穿越》,严谨的科学精神与深刻人文关怀(Re:C)" -> 1
[v] cplayer: Set property: file-local-options/stream-lavf-o={} -> 1
[debug] ytdl_hook: script running time: 0.0013839999999999 seconds
[v] ffmpeg: Opening http://upos-hz-mirrorwcsu.acgvideo.com/upgcxcode/30/00/67380030/67380030-1-64.flv?e=ig8euxZM2rNcNbKHhwdVhoMMnWdVhwdEto8g5X10ugNcXBlqNxHxNEVE5XREto8KqJZHUa6m5J0SqE85tZvEuENvNC8xNEVE9EKE9IMvXBvE2ENvNCImNEVEK9GVqJIwqa80WXIekXRE9IMvXBvEuENvNCImNEVEua6m2jIxux0CkF6s2JZv5x0DQJZY2F8SkXKE9IB5QK==&deadline=1564995413&gen=playurl&nbs=1&oi=628660170&os=wcsu&platform=pc&trid=537dfd13138e448ba7a4f6e6e87b9ac6&uipk=5&upsig=0a8c00050927b912d4ec6e1aada51434&uparams=e,deadline,gen,nbs,oi,os,platform,trid,uipk&mid=0
[debug] ffmpeg: tcp: Starting connection attempt to 220.242.128.184 port 80
[debug] ffmpeg: tcp: Successfully connected to 220.242.128.184 port 80
[v] ffmpeg: Could not set AVOption tls_verify='0'
[v] ffmpeg: Mime-type: 'video/x-flv'
[debug] ffmpeg: Stream opened successfully.
[v] cache: Cache size set to 20000 KiB (10000 KiB backbuffer)
[v] demux: Trying demuxers for level=normal.
[debug] demux: Trying demuxer: disc (force-level: normal)
[debug] demux: Trying demuxer: edl (force-level: normal)
[debug] demux: Trying demuxer: cue (force-level: normal)
[debug] demux: Trying demuxer: rawaudio (force-level: normal)
[debug] demux: Trying demuxer: rawvideo (force-level: normal)
[debug] demux: Trying demuxer: mkv (force-level: normal)
[debug] demux: Trying demuxer: libarchive (force-level: normal)
[debug] demux: Trying demuxer: rar (force-level: normal)
[debug] demux: Trying demuxer: lavf (force-level: normal)
[v] lavf: Found 'flv' at score=100 size=2048.
[debug] cache: request seek: 0 <= to=619 (cur=12459) <= 12459
[debug] ffmpeg/video: h264: Reinit context to 1280x720, pix_fmt: yuv420p
[v] lavf: avformat_find_stream_info() finished after 120155 bytes.
[v] demux: Detected file format: flv (libavformat)
[v] cache: blocking for STREAM_CTRL 6
[v] cplayer: Opening done: http://upos-hz-mirrorwcsu.acgvideo.com/upgcxcode/30/00/67380030/67380030-1-64.flv?e=ig8euxZM2rNcNbKHhwdVhoMMnWdVhwdEto8g5X10ugNcXBlqNxHxNEVE5XREto8KqJZHUa6m5J0SqE85tZvEuENvNC8xNEVE9EKE9IMvXBvE2ENvNCImNEVEK9GVqJIwqa80WXIekXRE9IMvXBvEuENvNCImNEVEua6m2jIxux0CkF6s2JZv5x0DQJZY2F8SkXKE9IB5QK==&deadline=1564995413&gen=playurl&nbs=1&oi=628660170&os=wcsu&platform=pc&trid=537dfd13138e448ba7a4f6e6e87b9ac6&uipk=5&upsig=0a8c00050927b912d4ec6e1aada51434&uparams=e,deadline,gen,nbs,oi,os,platform,trid,uipk&mid=0
[v] cplayer: Running hook: ytdl_hook/on_preloaded
[v] lavf: select track 0
[v] lavf: select track 1
[info] cplayer:  (+) Video --vid=1 (h264 1280x720 24.000fps)
[info] cplayer:  (+) Audio --aid=1 (aac 2ch 44100Hz)
[info] display-tags: File tags:
[info] display-tags:  Description: Codec by Bilibili XCode Worker v4.6.5(fixed_gap:False)
[v] vo/gpu: Probing for best GPU context.
[v] vo/gpu/opengl: Initializing GPU context 'cocoa'

But mpv work fine in terminal

mpv https://www.bilibili.com/video/av38334623?spm_id_from=333.45.b_63696e657068696c655f63696e656369736d.5.
@jaseg
Copy link
Owner

jaseg commented Nov 10, 2019

Hmm, I don't have a mac setup to test this on so I can't really help you. What might work is trying other vo options, or changing the vo parameters. Also try getting a debug log from the working mpv command line app, and compare the two logs. mpv sometimes behaves differently when called from the command line as opposed to when it is called via libmpv.

@retifrav
Copy link

retifrav commented Mar 13, 2022

Out of all the VO options listed there, only tct worked for me:

player = mpv.MPV(
    log_handler=print,
    loglevel="debug",
    vo="tct"
)

That's not ideal, of course, but at least it narrows down the problem, that on Mac OS there are some issues with initializing the context. Without specifying vo option my output stucks here too:

v vo/gpu Probing for best GPU context.
v vo/gpu/opengl Initializing GPU context 'cocoa'

and nothing happens after that, so I can only interrupt the execution with Ctrl + C.

Full script, just in case:

import mpv

player = mpv.MPV(
    log_handler=print,
    loglevel="debug"#,
    #vo="tct"
)

player.play("/path/to/some.mp4")
player.wait_for_playback()

My environment:

$ python --version
Python 3.9.10

$ mpv --version
mpv 0.34.1 Copyright © 2000-2021 mpv/MPlayer/mplayer2 projects
 built on Thu Feb  3 04:12:42 UTC 2022
FFmpeg library versions:
   libavutil       56.70.100
   libavcodec      58.134.100
   libavformat     58.76.100
   libswscale      5.9.100
   libavfilter     7.110.100
   libswresample   3.9.100
FFmpeg version: 4.4.1

$ sw_vers -productVersion
11.6.4

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