Mpv: [ytdl_hook] Unable to stream Youtube videos

Created on 11 Jan 2018  路  30Comments  路  Source: mpv-player/mpv

mpv version and platform

Windows 10 Home
mpv 0.28.0

Reproduction steps

mpv AYoutubeURL

Expected behavior

Streams the video.

Actual behavior

Cannot stream youtube video.
[ytdl_hook] youtube-dl failed, trying to play URL directly ...

Log file

https://pastebin.com/7VGFeEKe

notes

Youtube-dl itself can download the video. It has been placed in mpv directory.
Mpv is able to stream (some) other sites besides Youtube.
Internet connection (wired) and speeds are not a problem.

Most helpful comment

this problem can be solved by upgrading your youtube-dl(if you already have )
to upgrade use this
sudo pip install --upgrade youtube_dl
run it
enjoy

All 30 comments

Works fine here. There were a couple fixes for youtube-dl on git master already. Could you try with that or at least give a log with --msg-level=ytdl_hook=debug?

Erh, could you tell me how to try those fixes? I'm new to all this.
Here's the log
https://pastebin.com/VQAfqUx9

That doesn't seem like a mpv issue, could you run that command manually?
"C:/Program Files/mpv/youtube-dl" --no-warnings -J --flat-playlist --sub-format ass/srt/best --no-playlist --format best --no-check-certificate --all-subs -- https://www.youtube.com/watch?v=0_wtNwsAF3k

I'm not sure if this is what u wanted:

mpv "C:/Program Files/mpv/youtube-dl" --no-warnings -J --flat-playlist --sub-format ass/srt/bes
t --no-playlist --format best --no-check-certificate --all-subs -- https://www.youtube.com/watch?v=0_wtNwsAF3k
Error parsing option warnings (option not found)
Setting commandline option --no-warnings= failed.

Exiting... (Fatal error)

Remove "mpv" from the start. The point is to run youtube-dl with the same command mpv uses.

I use Powershell normally, I've included the cmd logs too.
https://pastebin.com/w6kbbmyp

Seems to work. Try with a newer build, maybe shinchiro's.

Okay, I've deleted the old mpv files and tried shinchiro's build (mpv-x86_64-20180110-git-0a406f9.7z).

mpv https://www.youtube.com/watch?v=0_wtNwsAF3k

Playing: https://www.youtube.com/watch?v=0_wtNwsAF3k
[ytdl_hook] youtube-dl failed
Failed to recognize file format.


Exiting... (Errors when loading file)

Add --log-file=whatever.txt to mpv's command and then pastebin it.

Honestly have no idea. Try moving that whole mpv directory elsewhere out of "Program Files".

And what's your youtube-dl version (run youtube-dl --version)?

youtube-dl --version
2018.01.07
I've moved it to %appdata% (C:\Users\steve\AppData\Roaming\mpv).
Same error in powershell.

Save this as ytdl_hook.lua inside your mpv's config directory, inside a directory called scripts and run with mpv --no-ytdl https://www.youtube.com/watch?v=0_wtNwsAF3k --msg-level=ytdl_hook=debug --log-file=whatever.txt and pastebin the log again.

Well, there's some issue with whatever youtube-dl executable you're using. Can you try installing python 3.6, then install youtube-dl through it (py -3 -m pip install youtube-dl).
Delete youtube-dl.exe from mpv's config dir and then make sure python's youtube-dl is in PATH by using where youtube-dl.exe. If this failed, add the directory Scripts inside python's install directory to the system PATH.

If this still doesn't fix it, I have no idea.

How do I use python? Where do I paste that in.

Powershell or cmd should be fine. The where command actually needs to be in cmd, not powershell.

youtube-dl.exe is in python's Scripts folder.
I've added C:\Users\steve\AppData\Local\Programs\Python\Python36-32Scripts into system PATH.
But running it again doesn't work.

mpv https://www.youtube.com/watch?v=0_wtNwsAF3k

Playing: https://www.youtube.com/watch?v=0_wtNwsAF3k
[ytdl_hook] youtube-dl failed
[ytdl_hook2] youtube-dl failed: not found or not enough permissions
[ytdl_hook3] youtube-dl failed: not found or not enough permissions
Failed to recognize file format.

Exiting... (Errors when loading file)

Also, I've noticed Mpv cannot stream videos from any site now(same errors as above).

FYI, if you run the Python installer, all required default directories should already be added to PATH.

_Edit:_

BTW, that's fishy.

C:\Users\steve\AppData\Local\Programs\Python\Python36-32Scripts

Python36-32?

Something is very wrong in your system or configuration.

If no one else can reproduce this, I'd say this is beyond this issue tracker.

Can you please download the 0.28 from here, extract it to some normal directory without spaces (e.g. c:\testmpv\), and then drag that youtube link onto the mpv.exe inside that dir? I'm thinking maybe there's more than one mpv or ytdl at the path which confuses things. And please use normal shell too (i.e. not power shell).

edit - seems it doesn't include youtube-dl.exe, so please download it from here and put it at the same dir as mpv.

@Hrxn
python installer
Whoops. Entirely my fault. There is another youtube-dl file I've placed in the mpv directory I downloaded from the official download page(the bolded link). Did not occur to me that it would affect anything.
youtubedl
(I did delete it from the mpv directory once, when asked to use the ytdl_hook.lua script.)

I fixed it by deleting mpv directories I had and reinstalled with just youtube-dl.exe this time.

What led me to download it was how slow mpv (actually youtube-dl.exe) was at retrieving the video (which was fixed by forcing ipv4 in the youtube-dl configs with -4, but didn't find this out until later). So I assumed something was wrong with mpv and it led to this. Sorry about the hassle.

Maybe mention the ipv4 thing in case somebody like me thinks it's mpvs fault.

TBH, it should look like this:
C:\Users\Hrxn\AppData\Local\Programs\Python\Python36

Only if it's not the 32-bit version.

Well, f.. me sideways, I think you're right.

this problem can be solved by upgrading your youtube-dl(if you already have )
to upgrade use this
sudo pip install --upgrade youtube_dl
run it
enjoy

Had the same issues and it was very strange indeed, I could only get it to work by installing youtube-dl from native windows python/pip. The official binary in the mpv folder (2020.06.16.1) wouldnt work and strangely enough would be skipped even though it's earlier in the search path. youtube-dl from cygwin pip also wouldnt work.

If you youtube-dl executable is just a python file with a shebang, it won't work, because we use CreateProcess, and Windows doesn't understand that.

No, it's the official release from their website, it's some compiled python binary for windows. The pip install on cygwin is actually a python file and just imports the modules or whatever, while the windows pip install is again a native binary.

I don't really use that youtube-dl function otherwise, as it's kinda cumbersome, especially with the blanket ytdl-format often getting it wrong, so I don't care to investigate this further, but just thought I would share my experience here to maybe help others.

The error message is really undescript and I would imagine wrong, too:

[   0.786][e][ytdl_hook]  
[   0.786][e][ytdl_hook] youtube-dl failed: not found or not enough permissions 
Was this page helpful?
0 / 5 - 0 ratings