Use mpv for video on URLs

Guys, moved to EOS few months back and using it exclusively now. Great distro.

Question: I use mpv to play youtube videos like so $mpv

I want to do the same for videos embedded in websites. Here is an example:

You can see there is a video in there. I tried mpv but to no avail. Mind you, this is not a live stream. It is a video snippet.

Any suggestions?

Second question: what about lives streams like


I tried for hours to get that to work, but no success.

Thanks

Have you tried play-with-mpv?
It works for me, but I didn’t test that video.

Thanks mcury that’s a good suggestion. Yes I did try that already.

Let me boot up my EOS system to check if I can tune something to get it working through mpv.
But, probably, if it’s not working with play-with-mpv, you will need to copy the video’s url, go to terminal, and type mpv followed by the url

The first link, you can’t right click on it… So play-with-mpv wouldn’t be an option. Maybe getting the url details pressing f12, copying to the terminal and playing through mpv…
The second link, you can press right click on it, but I couldn’t test because I just noticed that my play-with-mpv is broken… still need to check that…

[marcelo@linux ~]$ play-with-mpv 
Traceback (most recent call last):
  File "/usr/bin/play-with-mpv", line 33, in <module>
    sys.exit(load_entry_point('play-with-mpv==0.1.0.post5+g656448e', 'gui_scripts', 'play-with-mpv')())
  File "/usr/bin/play-with-mpv", line 22, in importlib_load_entry_point
    for entry_point in distribution(dist_name).entry_points
  File "/usr/lib/python3.9/importlib/metadata.py", line 524, in distribution
    return Distribution.from_name(distribution_name)
  File "/usr/lib/python3.9/importlib/metadata.py", line 187, in from_name
    raise PackageNotFoundError(name)
importlib.metadata.PackageNotFoundError: play-with-mpv
[marcelo@linux ~]$ play-with-mpv
Traceback (most recent call last):
  File "/usr/bin/play-with-mpv", line 33, in <module>
    sys.exit(load_entry_point('play-with-mpv==0.1.0.post5+g656448e', 'gui_scripts', 'play-with-mpv')())
  File "/usr/bin/play-with-mpv", line 22, in importlib_load_entry_point
    for entry_point in distribution(dist_name).entry_points
  File "/usr/lib/python3.9/importlib/metadata.py", line 524, in distribution
    return Distribution.from_name(distribution_name)
  File "/usr/lib/python3.9/importlib/metadata.py", line 187, in from_name
    raise PackageNotFoundError(name)
importlib.metadata.PackageNotFoundError: play-with-mpv

Yes, that is the problem. I cannot take the URL and pass it to mpv for first link. Second link croaks. Both cases, I am unable to use mpv.

Can you make the first one work? What URL did you get? Pl. share, so I can reverse-engineer at my end. Thanks!

Also, I use the play-with mpv extension on firefox: I think it is the same as the play-withmpv in aur. It does not work on both the streams.

What I could see through the html, is that is has a token.
I didn’t investigate with enough patience, but this is what I got from my first look at it:

image

It’s possible that you can only watch this through the browser…

Hmm… I see. No way you can use that m3u8 to play on mpv directly huh? I guess not if you feel so (you are more knowledgeable than me on this it seems). If you see any other way pl. let me know. My problem is that I use a v. old Intel atom based computer, and mpv is really the only way I can play video w/o all kinds of croaking. Youtube works perfectly, but this embedded video causes system to croak.

Thanks a lot bro!

I’m not an expert, don’t take my word as a last word on this!
I’m just an user that loves MPV, and knows networking and a little bit of html.
m3u8 is a playlist, not sure how MPV would handle that, maybe VLC would, I really don’t know.

Maybe it’s better to wait for someone with more knowledge than me to give you a definitive answer…

OK, so I know know thing that might help. If you invoke mpv with mpv -playlist, then it plays playlist. I do that sometimes for live streams on youtube. Will that help?

Thanks

I don’t think so, you would need to find the correct url to the video.
You can’t have urls with “,”

Yes it does appear so, I was trying to somehow construct the URL with the info on those few html lines, but I think that is too hard and maybe not possible.

Thanks all the same man!

1 Like

Maybe tomorrow someone will give you a better answer

tl;dr: Make sure you have youtube-dl installed, then use the m3u8 playlist URL mcury posted.

As far as I know MPV can’t play any URL’s directly on its own. If you pass it a URL, it passes that off to youtube-dl, which in turn, instead of saving whatever it’s downloading as a file, passes the result back to MPV.

With some sites (like youtube), youtube-dl knows how to extract the video automatically. If youtube-dl doesn’t know how to do that, though (like presumably with indiatvnews.com), it/mpv will fail, so you’ll need to help it find the video.

Anyway, if you have youtube-dl installed (you can get it with yay), MPV will definitely be able to play the m3u playlist mcury referenced. Another way to find it is to check the network tab in your browser’s inspector, and check for requests for videos (mp4 etc.) and/or playlists (like the m3u8 in this case). Example, for the site in question: https://i.imgur.com/jJLPVA1.png

From there just right-click and “copy url,” then pass it to mpv. And there you go: https://i.imgur.com/BNfEa6z.png

Edit: Sorry I missed the 2nd part of the question regarding the livestream. Generally you can do that in the same way described above, however this one is a little trickier because they block access to “non-browsers.”

mike:~$ curl -I 'https://z5ams.akamaized.net/out/v1/915deae3b9024babbe4e35748e296d34/hdntl=exp=1608001716~acl=%2f*~data=hdntl~hmac=d08639d7d9d7c88aa478ce897bbc2bf7253cc59194646c97f9b5a3b3767413ea/index_1.m3u8'
HTTP/1.1 403 Forbidden

Luckily youtube-dl can pass custom http headers, and the MPV devs were wise enough to include support for that. So you pass MPV the necessary header and it’ll forward that to the youtube-dl request. Something like[1]:

mpv --http-header-fields="User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:83.0) Gecko/20100101 Firefox/83.0" "https://z5ams.akamaized.net/out/v1/915deae3b9024babbe4e35748e296d34/index.m3u8?hdnts=st=1607915699~exp=1607918699~acl=/*~hmac=b5787a1c415bf0cd992093b03ab5a573d1f0964b4368d7301a3a769688ead81f"

[1] I suspect these URL’s expire and/or are tied to the requesting IP, so the above may not work for you – you might need to extract your own URL from your browser’s inspector.

1 Like