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

youtube-dl not working when running syncplay with iina or mpv #379

Closed
cordelac opened this issue Jan 18, 2021 · 14 comments · Fixed by #381
Closed

youtube-dl not working when running syncplay with iina or mpv #379

cordelac opened this issue Jan 18, 2021 · 14 comments · Fixed by #381
Assignees
Labels

Comments

@cordelac
Copy link

URL's aren't working when running syncplay with iina or mpv.

Failed to recognize file format.

However, URL's on both players work fine when outside syncplay. Tested with random youtube links.

OS - Big Sur 11.1 on M1
Syncplay: 1.6.7
youtube-dl: 2021.1.16
mpv: 0.33.0 // iina: 1.1.2 build 128

@Et0h Et0h assigned Et0h and albertosottile and unassigned Et0h Jan 18, 2021
@Et0h
Copy link
Contributor

Et0h commented Jan 18, 2021

Not being a Mac users I can't provide much support. I know on some platforms an issue can (or used to) occur if you open a file with Syncplay because that changes the PATH (base location) and so it looks for YTDL in the wrong place.

How are you running Syncplay?

@Et0h
Copy link
Contributor

Et0h commented Jan 18, 2021

As a workaround you might be able to put something along the files of the following in mpv.conf (with the path being the relevant path to youtube-dl):
script-opts=ytdl_hook-ytdl_path="/insert/path/here/youtube-dl"

If that works then let me know what worked.

@cordelac
Copy link
Author

Tried adding the path in mpv.conf, didn't work unfortunately.

I run Syncplay by opening it from Applications? I installed it via Homebrew (though it's the same downloading the dmg).

@albertosottile
Copy link
Member

albertosottile commented Jan 18, 2021

My gut says we are witnessing c07206c on steroids, a.k.a. we are mixing two Python interpreters compiled for two architectures (x86_64 in the Syncplay app and aarch64 in the system provided one used by youtube-dl).

How did you install youtube-dl? Did you use the version of Homebrew for x86_64 or for aarch64? Additionally, if you could open Terminal, run this command:

$(head -n 1 $(which youtube-dl) | cut -c 3-) -c "import platform; print(platform.platform())"

and report the result here, you could definitely help us.

(What does that do, you might ask? It finds youtube-dl in your system, asks which interpreter it uses to run, asks the same interpreter for which architecture it was compiled for).

@cordelac
Copy link
Author

Oh, I get it. I run Homebrew natively, so in terminal for youtube-dl I got:

macOS-11.1-arm64-arm-64bit

I guess I'll need an x86_64 version for Syncplay? In case it's relevant, my mpv is arm, while iina is still Intel

@albertosottile
Copy link
Member

You would actually need an arm64 version of Syncplay, but... there is none 😦 (see #368)

I guess we now need to think about how we can try to solve/mitigate this on our side. Thanks for reporting this and for your help.

@albertosottile
Copy link
Member

So, after a detailed investigation it seem that the CPU architecture might have nothing to do with this. I attempted a fix and pushed it on this repository, you can find the updated prerelease dmg in the action artifacts here: "direct" download (if that does not work, go to the job page and scroll down to find the artifacts, including the dmg).

@cordelac We would really appreciate if you could download this dmg, test it on your system, and report here the results. For the moment, youtube-dl should work with mpv but not with IINA, as for me IINA does not work with YouTube URLs even when running without Syncplay attached. Thanks for your time.

Side note: you might have to right click the executable twice before getting the Open button in the dialog... thanks, Apple.

@cordelac
Copy link
Author

Just tested on the linked 1.6.8, not working unfortunately. Still getting

Failed to recognize file format.

Appears to be acting as the same as it does in 1.6.7. If I can be of any further help, let me know

@albertosottile
Copy link
Member

Ok, it might be that there were more errors on top of each other... Since we are here, could you help us by retrieving a debug log from your system with the prerelease version that you just downloaded?

Here is how you can do so:

  • Open a Terminal and cd to the location of the prerelease Syncplay.app you downloaded earlier
  • Open Syncplay in debug mode and send the logs to the Desktop:
./Syncplay.app/Contents/MacOS/Syncplay --debug &> ~/Desktop/syncplay_debug.log
  • With Syncplay opened, try to play a video from YouTube as before. This should show in the GUI the same error from before.
  • After the error, quit Syncplay.
  • Send here the log file that should have appeared on your Desktop (or, if you prefer, just paste here all the player lines before player << youtube-dl failed: unexpected error occurred.

Thanks again for your help!

@cordelac
Copy link
Author

Okay, followed your instructions and got this:

[18:32:17] player << Python path configuration:
[18:32:17] player << PYTHONHOME = '/Applications/Syncplay.app/Contents/Resources'
[18:32:17] player << PYTHONPATH = '/Applications/Syncplay.app/Contents/Resources'
[18:32:17] player << program name = '/opt/homebrew/Cellar/youtube-dl/2021.1.16/libexec/bin/python3.9'
[18:32:17] player << isolated = 0
[18:32:17] player << environment = 1
[18:32:17] player << user site = 1
[18:32:17] player << import site = 1
[18:32:17] player << sys._base_executable = '/opt/homebrew/Cellar/youtube-dl/2021.1.16/libexec/bin/python3.9'
[18:32:17] player << sys.base_prefix = '/Applications/Syncplay.app/Contents/Resources'
[18:32:17] player << sys.base_exec_prefix = '/Applications/Syncplay.app/Contents/Resources'
[18:32:17] player << sys.platlibdir = 'lib'
[18:32:17] player << sys.executable = '/opt/homebrew/Cellar/youtube-dl/2021.1.16/libexec/bin/python3.9'
[18:32:17] player << sys.prefix = '/Applications/Syncplay.app/Contents/Resources'
[18:32:17] player << sys.exec_prefix = '/Applications/Syncplay.app/Contents/Resources'
[18:32:17] player << sys.path = [
[18:32:17] player << '/Applications/Syncplay.app/Contents/Resources',
[18:32:17] player << '/Applications/Syncplay.app/Contents/Resources/lib/python39.zip',
[18:32:17] player << '/Applications/Syncplay.app/Contents/Resources/lib/python3.9',
[18:32:17] player << '/Applications/Syncplay.app/Contents/Resources/lib/python3.9/lib-dynload',
[18:32:17] player << ]
[18:32:17] player << Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
[18:32:17] player << Python runtime state: core initialized
[18:32:17] player << ModuleNotFoundError: No module named 'encodings'
[18:32:17] player << Current thread 0x000000010461bd40 (most recent call first):
[18:32:17] player << <no Python frame>
[18:32:17] player << youtube-dl failed: unexpected error occurred

@albertosottile
Copy link
Member

I forgot that Homebrew on ARM has a different default prefix... Just to confirm, could you post here the result of which youtube-dl?. (I expect /opt/homebrew/bin/youtube-dl.)

Assuming that I got this right, I prepared another test build for you: direct download | build.

Could you download the updated DMG from here and try again? If it still fails, I would also appreciate the updated debug log taken as described before. Thank you again!

@cordelac
Copy link
Author

The result is /opt/homebrew/bin/youtube-dl,

and the latest version you prepared is working! Tested on iina (Intel) just in case, and it's also working great, thanks!

@tristan-k
Copy link

@albertosottile @cordelac Sadly the build link has been expired. Is there a binary for Apple Silicon M1 available somewhere else?

@albertosottile
Copy link
Member

@tristan-k The binary posted here was never an Apple Silicon binary, but merely a fix for youtube-dl. You can find a (very) preliminary universal2 binary here: #368 (comment)

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

Successfully merging a pull request may close this issue.

5 participants