软件更新后,mpv打不开了!!

Totem,mplayer,sopcast,realplayer,bmp
回复
linuxmm9
帖子: 214
注册时间: 2017-08-19 10:12
系统: linux

软件更新后,mpv打不开了!!

#1

帖子 linuxmm9 » 2020-12-03 18:03

软件更新后,mpv打不开了。
之前安装了一个mpv的脚本,可以只运行一个播放器.最近更新了软件,结果那个脚本就打不开了,终端里运行提示如下:

代码: 全选

Traceback (most recent call last):
  File "/home/abc/.config/mpv/./MPV", line 91, in <module>
    subprocess.check_call(opts)
  File "/usr/lib/python3.9/subprocess.py", line 373, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['mpv', '--no-terminal', '--force-window', '--input-file=/home/abc/.umpv_fifo', '--']' returned non-zero exit status 1.

附上脚本文件:

代码: 全选

#!/usr/bin/env python

"""
This script emulates "unique application" functionality on Linux. When starting
playback with this script, it will try to reuse an already running instance of
mpv (but only if that was started with umpv). Other mpv instances (not started
by umpv) are ignored, and the script doesn't know about them.
This only takes filenames as arguments. Custom options can't be used; the script
interprets them as filenames. If mpv is already running, the files passed to
umpv are appended to mpv's internal playlist. If a file does not exist or is
otherwise not playable, mpv will skip the playlist entry when attempting to
play it (from the GUI perspective, it's silently ignored).
If mpv isn't running yet, this script will start mpv and let it control the
current terminal. It will not write output to stdout/stderr, because this
will typically just fill ~/.xsession-errors with garbage.
mpv will terminate if there are no more files to play, and running the umpv
script after that will start a new mpv instance.
Note that you can control the mpv instance by writing to the command fifo:
    echo "cycle fullscreen" > ~/.umpv_fifo
Note: you can supply custom mpv path and options with the MPV environment
      variable. The environment variable will be split on whitespace, and the
      first item is used as path to mpv binary and the rest is passed as options
      _if_ the script starts mpv. If mpv is not started by the script (i.e. mpv
      is already running), this will be ignored.
"""

import sys
import os
import errno
import subprocess
import fcntl
import stat
import string

files = sys.argv[1:]

# this is the same method mpv uses to decide this
def is_url(filename):
    parts = filename.split("://", 1)
    if len(parts) < 2:
        return False
    # protocol prefix has no special characters => it's an URL
    allowed_symbols = string.ascii_letters + string.digits + '_'
    prefix = parts[0]
    return all(map(lambda c: c in allowed_symbols, prefix))

# make them absolute; also makes them safe against interpretation as options
def make_abs(filename):
    if not is_url(filename):
        return os.path.abspath(filename)
    return filename
files = [make_abs(f) for f in files]

FIFO = os.path.join(os.getenv("HOME"), ".umpv_fifo")

fifo_fd = -1
try:
    fifo_fd = os.open(FIFO, os.O_NONBLOCK | os.O_WRONLY)
except OSError as e:
    if e.errno == errno.ENXIO:
        pass  # pipe has no writer
    elif e.errno == errno.ENOENT:
        pass # doesn't exist
    else:
        raise e

if fifo_fd >= 0:
    # Unhandled race condition: what if mpv is terminating right now?
    fcntl.fcntl(fifo_fd, fcntl.F_SETFL, 0) # set blocking mode
    fifo = os.fdopen(fifo_fd, "w")
    for f in files:
        # escape: \ \n "
        f = f.replace("\\", "\\\\").replace("\"", "\\\"").replace("\n", "\\n")
        f = "\"" + f + "\""
        fifo.write("raw loadfile " + f + " \n")
else:
    # Recreate pipe if it doesn't already exist.
    # Also makes sure it's safe, and no other user can create a bogus pipe
    # that breaks security.
    try:
        os.unlink(FIFO)
    except OSError as e:
        pass
    os.mkfifo(FIFO, 0o600)

    opts = (os.getenv("MPV") or "mpv").split()
    opts.extend(["--no-terminal", "--force-window", "--input-file=" + FIFO,
                 "--"])
    opts.extend(files)

    subprocess.check_call(opts)
上次由 linuxmm9 在 2020-12-06 0:21,总共编辑 1 次。
头像
oneleaf
论坛管理员
帖子: 10441
注册时间: 2005-03-27 0:06
系统: Ubuntu 12.04

Re: 软件更新后,mpv打不开了!!

#2

帖子 oneleaf » 2020-12-03 18:14

问题出在这一行:

subprocess.CalledProcessError: Command '['mpv', '--no-terminal', '--force-window', '--input-file=/home/abc/.umpv_fifo', '--']' returned non-zero exit status 1.


应该是mpv升级后,不在支持某些参数导致的,你试试找出错误的参数,删除掉
linuxmm9
帖子: 214
注册时间: 2017-08-19 10:12
系统: linux

Re: 软件更新后,mpv打不开了!!

#3

帖子 linuxmm9 » 2020-12-03 19:01

oneleaf 写了: 2020-12-03 18:14 问题出在这一行:

subprocess.CalledProcessError: Command '['mpv', '--no-terminal', '--force-window', '--input-file=/home/abc/.umpv_fifo', '--']' returned non-zero exit status 1.


应该是mpv升级后,不在支持某些参数导致的,你试试找出错误的参数,删除掉
这个不懂啊 :Sad
头像
oneleaf
论坛管理员
帖子: 10441
注册时间: 2005-03-27 0:06
系统: Ubuntu 12.04

Re: 软件更新后,mpv打不开了!!

#4

帖子 oneleaf » 2020-12-03 19:21

将下面的命令运行一下,结果贴上来

mpv --no-terminal --force-window --input-file=/home/abc/.umpv_fifo --
linuxmm9
帖子: 214
注册时间: 2017-08-19 10:12
系统: linux

Re: 软件更新后,mpv打不开了!!

#5

帖子 linuxmm9 » 2020-12-03 19:36

oneleaf 写了: 2020-12-03 19:21 将下面的命令运行一下,结果贴上来

mpv --no-terminal --force-window --input-file=/home/abc/.umpv_fifo --
没有返回信息
funicorn
帖子: 1318
注册时间: 2005-09-13 4:56
系统: Ubuntu Jammy Jellyfi

Re: 软件更新后,mpv打不开了!!

#6

帖子 funicorn » 2020-12-03 20:53

代码: 全选

mpv --no-terminal --force-window --input-file=/home/abc/.umpv_fifo -- &
echo $?
头像
oneleaf
论坛管理员
帖子: 10441
注册时间: 2005-03-27 0:06
系统: Ubuntu 12.04

Re: 软件更新后,mpv打不开了!!

#7

帖子 oneleaf » 2020-12-03 21:18

看了下你报错的信息和脚本不匹配,运行下面的命令结果贴上来

cat /home/abc/.config/mpv/./MPV
linuxmm9
帖子: 214
注册时间: 2017-08-19 10:12
系统: linux

Re: 软件更新后,mpv打不开了!!

#8

帖子 linuxmm9 » 2020-12-03 23:04

谢谢管理员 问题解决了 是我没注意 原来github上的脚本已经更新过了 现在可以播放了 谢谢

新的文件:

代码: 全选

#!/usr/bin/env python3

"""
This script emulates "unique application" functionality on Linux. When starting
playback with this script, it will try to reuse an already running instance of
mpv (but only if that was started with umpv). Other mpv instances (not started
by umpv) are ignored, and the script doesn't know about them.
This only takes filenames as arguments. Custom options can't be used; the script
interprets them as filenames. If mpv is already running, the files passed to
umpv are appended to mpv's internal playlist. If a file does not exist or is
otherwise not playable, mpv will skip the playlist entry when attempting to
play it (from the GUI perspective, it's silently ignored).
If mpv isn't running yet, this script will start mpv and let it control the
current terminal. It will not write output to stdout/stderr, because this
will typically just fill ~/.xsession-errors with garbage.
mpv will terminate if there are no more files to play, and running the umpv
script after that will start a new mpv instance.
Note: you can supply custom mpv path and options with the MPV environment
      variable. The environment variable will be split on whitespace, and the
      first item is used as path to mpv binary and the rest is passed as options
      _if_ the script starts mpv. If mpv is not started by the script (i.e. mpv
      is already running), this will be ignored.
"""

import sys
import os
import socket
import errno
import subprocess
import fcntl
import stat
import string

files = sys.argv[1:]

# this is the same method mpv uses to decide this
def is_url(filename):
    parts = filename.split("://", 1)
    if len(parts) < 2:
        return False
    # protocol prefix has no special characters => it's an URL
    allowed_symbols = string.ascii_letters + string.digits + '_'
    prefix = parts[0]
    return all(map(lambda c: c in allowed_symbols, prefix))

# make them absolute; also makes them safe against interpretation as options
def make_abs(filename):
    if not is_url(filename):
        return os.path.abspath(filename)
    return filename
files = [make_abs(f) for f in files]

SOCK = os.path.join(os.getenv("HOME"), ".umpv_socket")

sock = None
try:
    sock = socket.socket(socket.AF_UNIX)
    sock.connect(SOCK)
except socket.error as e:
    if e.errno == errno.ECONNREFUSED:
        sock = None
        pass  # abandoned socket
    elif e.errno == errno.ENOENT:
        sock = None
        pass # doesn't exist
    else:
        raise e

if sock:
    # Unhandled race condition: what if mpv is terminating right now?
    for f in files:
        # escape: \ \n "
        f = f.replace("\\", "\\\\").replace("\"", "\\\"").replace("\n", "\\n")
        f = "\"" + f + "\""
        sock.send(("raw loadfile " + f + " \n").encode("utf-8"))
else:
    # Let mpv recreate socket if it doesn't already exist.

    opts = (os.getenv("MPV") or "mpv").split()
    opts.extend(["--no-terminal", "--force-window", "--input-ipc-server=" + SOCK,
                 "--"])
    opts.extend(files)

    subprocess.check_call(opts)
回复