mpv
mpv copied to clipboard
Support SOCKS5 proxies
It would be nice to have a config item like socks_proxy or socks5_proxy to support SOCKS proxies.
At the moment, even commands like tsocks mpv http://server/test.webm fail to work, and though curl --socks5 localhost:1080 http://server/test.webm |mpv --cache=512 works, you can't seek since mpv isn't controlling the network stream.
This SO question explains the issue farther.
If you can use a regular HTTP proxy instead of a SOCKS proxy, you can set the environment variable HTTP_PROXY="url" to make FFmpeg and youtube-dl pick up on it.
Judging by a quick glance at FFmpeg code, it doesn't seem to support socks proxies at all, so any support for them in mpv would be blocked by this. (Also keep in mind that youtube-dl would also need support for them if you plan on using it)
The combination of privoxy, HTTP_PROXY/HTTPS_PROXY as envvar and youtube-dl works well enough. I would argue that additional code for this in mpv would be an unnecessary burden to maintain.
Why do you need socks5?
There is no a good open source SOCKS 5 server available.
OpenSSH is an open source SOCKS 5 server. It's even the one I use (ssh -D1080 myserver). I do not use an HTTP proxy and am not interested in setting one up on my remote server. If the right move is to escalate to FFMPEG (and youtube-dl), then so be it. I was just hoping it would be attractive enough to implement here.
I just found this after looking at the man page and not seeing anything socks related. At least for the youtube-dl integration it works for me, like this:
http_proxy=socks5://127.0.0.1:9050 mpv [...]
mpv 0.18.0 youtube-dl 2016.07.09.2
@v2px I tried
http_proxy=socks5://127.0.0.1:9050 mpv [...]
But it no longer works. Found polipo to the rescue.
Btw, I forgot to mention this, but proxychains mpv works fine. I use it for watching youtube videos over tor (which also exposes a SOCKS proxy).
Hope mpv could provide proxy support, might you not know, the VPNs are slaughtered in some countries, like China, Iran, North Korea, and people of those nations have to set up socks and http proxy to get the Youtube, Google and so on. So nicely handy thing if MPV could have a proxy support.
@haasn yeap, proxychains is good at linux and unices, but in windows, it is hard to find a handy way except a proxy included in mpv.
I would also love SOCKS proxy support. It's the proxy of choice for Tor.
resolved.
first, set your environment variable with:
$ set http_proxy=http://127.0.0.1:1080
$ set https_proxy=http://127.0.0.1:1080
second, with privoxy or gost to transfer remote socks5 proxy service to a local http proxy port -> 127.0.0.1:1080.
then mpv can use local http proxy instead of any socks ones.
AFAIK, the http_proxy envvar will cover both secure and non-secure http variants, so no need for a set https=... one?
But otherwise, good info I guess.
@garoto This is application dependant and I wouldn't trust all programs to get this right. It doesn't hurt to simply
export http_proxy=http://127.0.0.1:8118
export HTTP_PROXY="$http_proxy"
export https_proxy="$http_proxy"
export HTTPS_PROXY="$http_proxy"
export ftp_proxy="$http_proxy"
export rsync_proxy="$http_proxy"
export no_proxy="localhost,127.0.0.1"
to reduce risk of information leaks.
If that's the case, then it sucks that there's no conventional way of doing it. Feels kinda dirty to polute your shell .rc with what might be redundant envvars afterall... (I'm on Windows btw).
@lamarpavel in Xinux, you can do better with proxychains-ng, u can use socks proxy directly instead of transfer for http proxy.
so, what I said is just for M$ windows.
@garoto AFAIK, the http_proxy envvar will cover both secure and non-secure http variants, so no need for a set https=... one?
bad news, in Win 10, you have to also set https_proxy env, or you can not access https website by proxy.
Ugh, I find it hard to believe that there's logic bult in "Win10" to differentiate between a http_proxy and a https_proxy env. variable, but who knows right?
this is my workout in one line command with win 10:
cmd.exe /C "set http_proxy=http://127.0.0.1:1080 && set https_proxy=http://127.0.0.1:1080 && c:\mpv.exe "URL""
and before that, have to run privoxy first to convert socks5 proxy to http proxy.
terrible experience ...
Is this still not something that we can get? It's been a request for 2 years now.
I mean, you can do something like:
mpv --ytdl-raw-options=proxy=[socks5://localhost:9050] videolinkhere
But there is some confusing language in the manual about this:
"A proxy URL can be passed for youtube-dl to use it in parsing the website. This is useful for geo-restricted URLs. After youtube-dl parsing, some URLs also require a proxy for playback, so this can pass that proxy information to mpv. Take note that SOCKS proxies aren't supported and https URLs also bypass the proxy. This is a limitation in FFmpeg."
Judging by this text it is half supported, and you must choose between HTTPS or Proxy/Tor?
youtube-dl is only used to fetch the actual URL of the video (generally a googlevideo.com one) and then that URL is passed to the ffmpeg http downloader code, which doesnt support socks proxies.
For instance, if you feed the output of the command below to ffplay you get video:
$ youtube-dl.exe --get-url https://www.youtube.com/watch?v=8EKl9aF4NnM
I think Justsoos idea of using gost as a forwarder works great and probably the best solution right now.
https://github.com/mpv-player/mpv/issues/3373#issuecomment-345519593
in general, if you run mpv behind proxy, it must be a http proxy, if you have only socks proxy, transfer it to local http proxy first by privoxy or gost.
run it like, assuming your http proxy is 127.0.0.1:1080:
http_proxy=http://127.0.0.1:1080 mpv $URL
the http:// must be there, or error
if you run mpv to see youtube, you have to install youtube-dl first and run command line like:
http_proxy=http://127.0.0.1:1080 mpv --ytdl-raw-options=proxy=%14%127.0.0.1:1080 $YOUTUBE_URL
this command seems a CRAZY one which you MUST NOT change any letter of:
http_proxy=http://
and
proxy=%14%127.0.0.1:1080
the number 14 is the length of 127.0.0.1:1080, include the punctuation characters, if your proxy's word-length is not exact like my example, pls count them by yourself.
another way to avoid that maddening shackles is setting the mpv.conf like:
ytdl=yes
ytdl-raw-options=proxy=[http://127.0.0.1:1080]
so you do not need to count the numbers on your screen...
but you still need to run mpv like:
http_proxy=http://127.0.0.1:1080 mpv $YOUTUBE_URL
that is a flatter programmer's game, not for users, enjoy it!
@lamarpavel, @Justsoos is there a guide how to setup privoxy to convert socks5 proxy to http(s)?
Why do you need socks5?
There is no a good open source SOCKS 5 server available.
https://3proxy.ru
Still no acceptable solution except using vpn?
You can just forget about HTTP proxies, no video hosting does not work with http protocol!
I can't find a normal HTTPS proxy, they all give the error curl: (35) OpenSSL/3.1.4: error:0A00010B:SSL routines::wrong
version number
I can't always use vpn, so I need to be accessible from outside.
SOCKS5 is a perfect solution that works with browser and curl.
But unfortunately it doesn't work anymore neither through http nor through socks5 proxy. :-( YouTube somehow understands that proxy is used. yt-dlp --proxy socks5://127.0.0.1:1080 -F https://www.youtube.com/watch?v=glfh9XC-p9Q
[youtube] Extracting URL: https://www.youtube.com/watch?v=glfh9XC-p9Q
[youtube] glfh9XC-p9Q: Downloading webpage
[youtube] glfh9XC-p9Q: Downloading ios player API JSON
[youtube] glfh9XC-p9Q: Downloading web creator player API JSON
ERROR: [youtube] glfh9XC-p9Q: Sign in to confirm you’re not a bot. This helps protect our community. Learn more
yt-dlp --proxy http://127.0.0.1:3128 -F https://www.youtube.com/watch?v=glfh9XC-p9Q
[youtube] Extracting URL: https://www.youtube.com/watch?v=glfh9XC-p9Q
[youtube] glfh9XC-p9Q: Downloading webpage
[youtube] glfh9XC-p9Q: Downloading ios player API JSON
[youtube] glfh9XC-p9Q: Downloading web creator player API JSON
ERROR: [youtube] glfh9XC-p9Q: Sign in to confirm you’re not a bot. This helps protect our community. Learn more
@lamarpavel, @Justsoos is there a guide how to setup
privoxyto convert socks5 proxy to http(s)?
I used 3proxy for this. /var/lib/3proxy/3proxy.cfg
auth iponly
allow * 127.0.0.1 *
parent 1000 socks5 SERVER PORT USER PASSWORD
socks -p1080
proxy -a -p3128
3proxy /var/lib/3proxy/3proxy.cfg For test
curl -x socks5://127.0.0.1:1080 https://2ip.io
curl -x http://127.0.0.1:3128 https://2ip.io
The problem is that it doesn't work with YouTube anymore. :-(
https://en.wikipedia.org/wiki/Censorship_of_YouTube
I miss doing mpv https://youtube.com... :-(
Tried proxychains with no luck too.