Mpv.NET-lib- icon indicating copy to clipboard operation
Mpv.NET-lib- copied to clipboard

youtube-dl fails to load video using mpv.net-lib with recent versions of mpvlib/ytdl

Open GrumpyBear57 opened this issue 3 years ago • 1 comments

Mpv.NET (lib) Version v1.2.0

Describe the bug I'm unable to get youtube videos to play, in either my own application (which I thought was at fault at first since it's .NET Core 3.1 WPF) or the example application provided in this repo.

I've tested several different combinations of different versions mpvlib, ytdl, and the ytdl-hooks lua script.

  • Latest version of each (as of posting)
  • Versions included in example WPF project
  • Version of mpvlib included in example WPF project with new ytdl version (with new and included ytdl-hooks)
  • New version of mpvlib with existing version of ytdl (with new and included ytdl-hooks)
  • X64 and X86 builds of latest version of each, unfortunately I don't know what version is included in the example, so I can't test the X64 build of that one

I figure the reason why keeping all existing versions the same fails is because ytdl is out of date and no longer works on youtube, so I updated it to the latest (which I tested, and it works in the latest version of mpv standalone), but that still didn't work so I updated the ytdl-hooks script, still nothing, and as I already knew updating the the latest mpv also doesn't work.

To Reproduce Steps to reproduce the behavior:

  1. Download the latest version of mpvlib, ytdl, and ytdl-hooks and drop in lib/ folder of example wpf project
  2. Add player.EnableYouTubeDl(); before player.Load()
  3. Change player.Load() to use a youtube URL (I've tried several, but the one I'm currently using is player.Load("https://www.youtube.com/watch?v=PXFFEM2UxmY"); FWIW)
  4. Build and run the project
  5. Application window opens, but stays empty

Expected behavior The youtube video should load and start playing in the application window

Additional context Here's the MpvLogLevel.Debug output https://gist.github.com/GrumpyBear57/3d46c7411b7cf6179520bdbe7eabc95a To me it looks like ytdl is technically running, just failing to grab the video from yt properly, but when I run youtube-dl.exe -F https://www.youtube.com/watch?v=PXFFEM2UxmY (or with -f bestvideo) directly from the lib/ directory, it works fine, and as mentioned above, using the same ytdl exe works with mpv standalone.

Interestingly, when I set my own project to debug log, I don't get any output when loading a youtube video, but do when loading a local file. Again, I'm running .NET Core 3.1 for that, so that may be an explanation as to minor differences in output?

Any help figuring this out would be greatly appreciated, let me know if you need any additional information or testing from me.

EDIT: Fixed typo I had in my youtube url, it still fails with the same output, but actually links to the video now

EDIT 2: Some additional things I forgot to mention but realized I probably should (will add more edits here if I think of anything else to test -- unless I fix it, then I'll post a new comment)

  • Yes I updated ytdl-hooks.lua to set path = "lib\\youtube-dl.exe" (even tried doing ./lib/youtube-dl.exe for shits and giggles), along with checking file permissions on it (windows did seem to be blocking it at first, but after unblocking it it still doesn't work)
  • I also attempted to manually set the video quality by adding player.YouTubeDlVideoQuality = YouTubeDlVideoQuality.Medium; before player.Load() to no avail

GrumpyBear57 avatar Jun 28 '21 17:06 GrumpyBear57

I know it's been over a year but have you resolved this by any chance?

If not, youtube-dl has been superseeded by yt-dlp so you could try upgrading to this.

Also, in your log I saw error [ytdl_hook] youtube-dl failed: not found or not enough permissions so make sure that the youtube-dl.exe or yt-dlp.exe are set to be copied to the output directory as per the instructions in the README.

hudec117 avatar Jul 04 '22 20:07 hudec117