hudec117 / Mpv.NET-lib-

.NET embeddable video/media player based on mpv for WinForms and WPF
MIT License
138 stars 36 forks source link

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

Open GrumpyBear57 opened 3 years ago

GrumpyBear57 commented 3 years ago

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.

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)

hudec117 commented 2 years ago

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.