mpv.el icon indicating copy to clipboard operation
mpv.el copied to clipboard

Failed to connect to MPV (continuation). Problems to in MAC.

Open AtomicNess123 opened this issue 2 years ago • 4 comments

I opened a similar issue time ago because I wasn't specifying a video file (stupid me!), but this time I am getting the error even when specifying it.

Debugger entered--Lisp error: (error "Failed to connect to mpv")
  signal(error ("Failed to connect to mpv"))
  error("Failed to connect to mpv")
  mpv-start("/Users/user/Desktop/vid.mp4")
  mpv-play("/Users/user/Desktop/vid.mp4")
  funcall-interactively(mpv-play "/Users/user/Desktop/vid.mp4")
  call-interactively(mpv-play record nil)
  command-execute(mpv-play record)
  helm-M-x-execute-command(mpv-play)
  helm-execute-selection-action-1()
  helm-execute-selection-action()
  funcall-interactively(helm-M-x nil)
  call-interactively(helm-M-x nil nil)
  command-execute(helm-M-x)

The reason why it isn't working could be because of pesky MAC security features. So I added Emacs and Ruby to Full Disk access. Did not work.

The mpv package works perfectly on Linux, it must therefore be a MAC security feature thats stopping it working.

The Emacs mpv package uses the json-ipc mpv interface, which creates a socket so that mpv can be controlled with emacs. So I tried the example in the mpv manual with socat to know if mpv is creating the socket and the json-ipc interface is working. However, it was working, so mpv is creating the socket and I can connect to it with socat.

So the issue must be with Emacs and the mpv package I wonder if emacs cant find the path to the mpv binary. So I added it:

(defcustom mpv-executable "/usr/local/bin/mpv"
  "Name or path to the mpv executable."
  :type 'file
  :group 'mpv)

Reloaded / pkilled Emacs, and restarted.

M-x mpv-play myvideo

It didn't work :(

AtomicNess123 avatar Dec 15 '22 10:12 AtomicNess123

I have the same problem on Debian 11 and on virtual machines Debian 10: "error: Failed to connect to mpv". I have in my init.el:

(require 'mpv)
(mpv-start "--idle=once")
(defcustom mpv-executable "/usr/bin/mpv"
  "Name or path to the mpv executable."
  :type 'file
  :group 'mpv)

At the same time: (mpv-version)"0.32.0".

soilc avatar May 15 '23 16:05 soilc

I experienced this problem too on Debian.

When I increased the 'mpv-start-timeout' variable from the default value of 0.5 seconds to 5.0 seconds the issue disappeared. (It appears that on my machine mpv was simply taking longer than 0.5 seconds to start, and so triggering the 'failed to connect' timeout error message.)

The 'mpv-start-timeout' variable is a customizable variable as so can be changed interactively via 'M-x customize', or in your init.el file by adding for example: (customize-set-variable 'mpv-start-timeout 5.0)

Linden6 avatar Sep 27 '23 16:09 Linden6

Linden6: Thank you very much! This actually works on Debian!

soilc avatar Oct 28 '23 17:10 soilc

@AtomicNess123 What version of the package were you using?

Older versions of the package implement (mpv-start) with --input-unix-socket, which is an outdated flag. These older versions are on non NonGNU ELPA and I suspect on MELPA.

The Github repo has an updated version of the package, which uses --input-ipc-server instead. Installing with use-package and Quelpa:

(use-package mpv
  :quelpa (mpv :fetcher github :repo "kljohann/mpv.el"))

kennethbruskiewicz avatar Dec 14 '23 19:12 kennethbruskiewicz