mpv-player / mpv

🎥 Command line video player
https://mpv.io
Other
28.54k stars 2.92k forks source link

Cant Open any YouTube link #9624

Closed hexxone closed 2 years ago

hexxone commented 2 years ago

Important Information

Provide following Information:

Reproduction steps

Drag & Drop any YouTube Link like: https://www.youtube.com/watch?v=Z-eooUWgtHw

The mpv player shows the thumbnail for a second, then just crashes.

Expected behavior

Play the video, or do just anything at all

Actual behavior

Minimizing & Crashing

Log file

There is no log getting created. No output written to the console. Nothing ???

ghost commented 2 years ago

It appears you may be missing youtube-dl or yt-dlp binaries. One of these are needed to play youtube videos. Get yt-dlp instead, for reasons such as fixed youtube speed throttle as of time of writing this.

You may need get a little advanced and configure mpv through command-line or adding mpv.conf in the same directory as mpv, then add options there.

For example putting this inside mpv.conf;

script-opts=ytdl_hook-ytdl_path="C:\babayada\yt-dlp\yt-dlp.exe"

You may point the conf if you need it to be somewhere else, point to its default config directory with other config files you may need using cmd, or create batch files for example launch.bat to launch mpv with options easily;

mpv.exe --force-window=yes --idle --config-dir="C:\bebebebebe\config_directory"

The --idle and --force-window=yes helps keeping the window open. You can jam those options inside mpv.conf, too. You may also redact those -- lines if they're inside mpv.conf.

Incidentally, you may also need Ffmpeg binaries to play youtube, I think. Download that and point to its extracted bin folder as follows within mpv.conf;

Edit 3: As of writing this, I don't know if it actually works.

ytdl-raw-options=ffmpeg-location="C:\bibobubu\ffmpeg\bin"

Some of these options are found in ffmpeg and youtube-dl/yt-dlp documentation. As for mpv's, it is found here.

Edit 4: As of writing, I don't know how to point mpv to the ffmpeg's bin path outside of yt-dl config. So the only way is through the %PATH% environment variable.

For example, by manually adding to path every .bat launch, how ever I don't know how to test if it works;

SET PATH=C:\ffmpeg\bin;%PATH%

Edit 2: Additionally, if you want console output, launch the mpv.com instead of mpv.exe.

Edit 1: Corrections

Thank you.

nobef commented 2 years ago

@01yakiek I can't understand either. I have yt-dlp in C: /Temp/yt-dlp.exe (I installed it according to some instructions) and ffmpeg in C: / ffmpeg (there are 3 files with exe extension). Mpv.conf in user/appdata/roaming/mpv by default. What do i do? There are no bin. There are no instructions, I cannot understand

CounterPillow commented 2 years ago

Put yt-dlp.exe next to mpv.exe. That's literally all you have to do.

nobef commented 2 years ago

@CounterPillow Remove from the original folder or copy another one?

ghost commented 2 years ago

@bamper45 Yes. (Edit: I mean, remove from original folder, there's no point keeping in that original folder)

Okay let me explain if anyone else is still confused, for the non-tech savvy, this is written for windows users.

Mpv does not have the ability to detect youtube-dl, yt-dlp, ffmpeg, config files, or etc everywhere except in three locations; the default config location "%appdata%\mpv", its own directory where the mpv.exe is, and the environment variables such as the %PATH%.

This is why I said configure mpv to tell it where those files are, it's best way to avoid all headaches. This info is written in the mpv's reference manual link I gave above.

As for ytdl_path config, the description reads as follows:

ytdl_path=youtube-dl
    Configure paths to youtube-dl's executable or a compatible fork's.
    The paths should be separated by : on Unix and ; on Windows.
    Mpv looks in order for the configured paths in PATH and in mpv's config directory.
    The defaults are "yt-dlp", "yt-dlp_x86" and "youtube-dl".
    On Windows the suffix extension ".exe" is always appended.

The info above mentions the PATH, which is the window's environment path that gives programs ability to know where most used binaries are.

For example if you installed ffmpeg via the installer instead of extracting the zip as portable use, the path to the ffmpeg's bin folder will be added to the %PATH%. Mpv and yt-dlp will detect it.

However, as of writing this, yt-dlp does not release with installer for windows (correct me if I'm wrong) unless you're using python, which then you can install via python's pip.

Which means without adding yt-dlp to the %PATH% that is done by installing via installer, mpv has no way to tell where yt-dlp is installed unless you specifically points its config to the location, or put youtube-dl.exe/yt-dlp.exe in same folder as mpv.exe. You can also put it in "%appdata%\mpv" if you choose to, or add to the environment variables such as %PATH% if you're more advanced.

You can find the information about how mpv handles its working directories and environment path can be found all the way at the bottom of the reference manual.

tl;dr: Put yt-dlp.exe next to mpv.exe. Else mpv can't find yt-dlp.exe because of reasons. Certainly there is no need to keep yt-dlp.exe anywhere else, because no programs will find them to use them anyway.

Thank you.

nobef commented 2 years ago

@01yakiek Thank you, very clear and detailed. But one more question, I have installed yt-dlp also for downloading videos from youtube. So you don't need to delete from the original folder if you want to download a video? Sorry for the meticulousness, but I want to understand once and for all, because I have been looking for answers for a long time.

ghost commented 2 years ago

@bamper45 No worries. I am quite happy to help!

Well, it depends on how do you download videos via yt-dlp.exe. Because I don't know how do you use yt-dlp to download videos.

For example if you use some kind of third-party software to download videos using yt-dlp, such that it specifically configured to detect yt-dlp only on "C:/Temp/yt-dlp.exe", then I suppose you should keep it there. Unless the software has the option to change the location of yt-dlp.exe. Then you can configure it to point to the yt-dlp.exe in mpv folder.

Edit 1: Unless the third party software actually downloads and updates yt-dlp.exe to "C:/Temp/yt-dlp.exe", I suppose you can just leave it there. Or again, you can point it to the mpv folder so it can use and download yt-dlp.exe to mpv folder simultaneously allows it to update yt-dlp.exe whenever possible, a win-win.

Alternatively, unless you're an advanced user write your own scripting files such as batch, powershell, python, or some other languages to launch yt-dlp.exe specifically configured on "C:/Temp/yt-dlp.exe", then you can leave it there untouched and just duplicate yt-dlp.exe, one for download-videos, and one for mpv inside the mpv folder. Or modify your scripting files it to point it to the new yt-dlp.exe location.

Or, you could also reorganize your file structures and use relative paths to make everything portable: 2021-12-24_05 34 38_Friday

For example the screenshot above, I keep ffmpeg, mpv, and yt-dlp in separate folders. Each have their own use and function.

Then each of these can be configured in a way that they are all connected through relative paths, so they can make use of each other.

mpv launch .bat command line inside mpv folder (only if you don't have ffmpeg installed in %PATH%), this is not permanent change to the %PATH%, only scoped to the running process:

SET PATH=%~dp0..\ffmpeg\bin;%PATH%
"mpv.exe"

mpv.conf inside mpv folder:

script-opts=ytdl_hook-ytdl_path="..\yt-dlp\yt-dlp.exe"
ytdl-raw-options=ffmpeg-location="..\ffmpeg\bin"

yt-dlp.conf inside yt-dlp folder:

--ffmpeg-location "..\ffmpeg\bin"

Then you can quite literally jam the example portable_programs folder containing ffmpeg, mpv, and yt-dlp inside thumbdrive/flash drive/sd card/whatever portable storage and it will work right off the bat portable across supported windows!

(This is a rough example, it may not work properly as I didn't test it especially for different use cases, I only took bits from my environment to construct an example)

Edit 2: Corrections

Thank you.

nobef commented 2 years ago

@01yakiek I think I got it, thanks for the detailed explanation!

Soromeister commented 2 years ago

Hi, I have FFMPEG in PATH, system install so if I pop-up the cmd and type "ffmpeg" I get help output with ffmpeg version. I have placed ytdl near mpv.exe and also linked it through ytdl_hook-ytdl_path="C:\Program Files\mpv\yt-dlp.exe" but I still cannot play youtube videos.

ghost commented 2 years ago

@Sorin-M-Oprea You forgot to use --script-ops. ytdl_hook-ytdl_path can only be used in the --script-ops as far as I could tell as documented here.

Taken from the hyperlink documentation as of writing this:

This accepts a set of options, which can be passed to it with the --script-opts option (using ytdl_hook- as prefix):

So the correct way is:

--script-opts=ytdl_hook-ytdl_path="C:\Program Files\mpv\yt-dlp.exe" 
CounterPillow commented 2 years ago

There is a lot of bad advice in here, so let me clarify a few things:

  1. if you place yt-dlp.exe next to mpv.exe, you do not need to set the ytdl_path. Setting it to an incorrect path in fact prevents mpv from finding yt-dlp
  2. You do not need to install ffmpeg at all.
  3. You do not need to change anything about your PATH

All you have to do is place yt-dlp.exe next to mpv.exe. Everything else in this issue is unhelpful hoops you don't need to jump through, and which will make it not work if you jump through them the wrong way.

Soromeister commented 2 years ago

I fixed my issue by downloading a new MPV version. Thanks for all the advice.