henry_shadowjet
Posts: 8
Joined: Mon Feb 27, 2017 7:59 am
Location: Sydney, Australia
Contact: Yahoo Messenger

OMXplayer - how to choose better streams with m3u8 playback?

Thu Sep 20, 2018 10:21 am

Hi fellow Raspbian users,

I'm currently puzzled as to how to instruct Raspbian to play a higher stream quality when given an m3u8 file.

For example, when given: http://edge.metrotvnews.com:1935/live-e ... ylist.m3u8
OMXPlayer always automatically get the worst quality (which is probably the first line in the file).

While I get that usually I can just download the m3u8 file, the manually extract the link that leads to the higher quality stream, and it certainly works in case for the stream above, it's not always ideal.
For instance, when I want to watch the stream from this link: https://www.vidio.com/live/734-trans7-tv-stream
This website protects its link by making it forbidden to access if it's not accessed by the master.m3u8, so trying to manually get the link for the higher streams always results in "403 Forbidden". Even playing from the master.m3u8, one has to be quick in copying and pasting the link before the video loads on the website, I think there is a time protection on it as well.
So for the case above, the first method doesn't work.

I tried to also use livestreamer, but on Raspbian it somehow always gives the error like this: "error: No plugin can handle URL: [insert URl here]". When I use my laptop the same link doesn't give a problem, the plugin is found, and the video is loaded. But for the particular link above (Trans7), it doesn't work, gives the "403 forbidden" yet again. So livestreamer solution is also out.

I'll be happy to receive any help or suggestion about how to go about doing this.
Thanks a lot in advance!

tvjon
Posts: 706
Joined: Mon Jan 07, 2013 9:11 am

Re: OMXplayer - how to choose better streams with m3u8 playback?

Thu Sep 20, 2018 5:52 pm

Presumably you use

http://edge.metrotvnews.com:1935/live-e ... sleng.m3u8

for the first link?

What omxplayer incantation do you use?


So what does a high quality stream from

https://www.vidio.com/live/734-trans7-tv-stream

look like?

The other attached screenshot is from the URL you supplied.

Livestreamer works fine with omxplayer. I use it for ISS reception. Again, what arguments are you using?

For the Trans7 stream you should find

streamlink, livestreamer's successor, to work well.

sudo apt install streamlink

For omxplayer, streaming input is handled by ffmpeg, so another source of info' regarding your URL's may be ffmpeg forums.
The attachment first-url.jpg is no longer available
The attachment first-url.jpg is no longer available
first-url.jpg
first-url.jpg (64.01 KiB) Viewed 2154 times
Edit: forum won't allow me to post a second jpeg...

henry_shadowjet
Posts: 8
Joined: Mon Feb 27, 2017 7:59 am
Location: Sydney, Australia
Contact: Yahoo Messenger

Re: OMXplayer - how to choose better streams with m3u8 playback?

Thu Jan 31, 2019 4:41 am

Thanks for the reply. That's quite a detailed response I got, thanks.

My apologies for not checking in for some time. I managed to get it working with Livestreamer, but I found out Livestreamer also have weaknesses. I'll be sure to check out Streamlink as per your suggestion, thanks!

The arguments I use for live stream is typically:
omxplayer -o alsa --no-ghost-box --align center --timeout 60 --live [the m3u8 link]
For livestreamer, I use the following command:
livestreamer -p "omxplayer -o alsa --no-ghost-box --align center --timeout 60 --live" --retry-open 9 -n "hlsvariant://[link to m3u8 file]"

I'm gonna give the streamlink a go and let you know what's the result.

Thanks again!

User avatar
RPi_Mike
Posts: 191
Joined: Sat Dec 09, 2017 12:57 am
Location: United States

Re: OMXplayer - how to choose better streams with m3u8 playback?

Thu Jan 31, 2019 7:53 am

henry_shadowjet wrote:
Thu Sep 20, 2018 10:21 am
I'm currently puzzled as to how to instruct Raspbian to play a higher stream quality when given an m3u8 file.

For example, when given: http://edge.metrotvnews.com:1935/live-edge/smil:metro.smil/playlist.m3u8
OMXPlayer always automatically get the worst quality (which is probably the first line in the file).

Perhaps you might like my GPU-accelerated software suite of FFmpeg, mpv and youtube-dl.

I tested it with the news link you mention by simply running the following command line:

mpv http://edge.metrotvnews.com:1935/live-edge/smil:metro.smil/playlist.m3u8

When I did that, my build of mpv automatically played the highest-quality stream available! The overall connection quality to a site like metrotvnews, however, is not going to be able to compete with the vast global infrastructure of a site like YouTube – so your mileage may of course vary.

As for the other site you mention, it definitely sounds like their video streams are deliberately obfuscated. I'm sure they have a good reason for that, however – so it is what it is.

henry_shadowjet
Posts: 8
Joined: Mon Feb 27, 2017 7:59 am
Location: Sydney, Australia
Contact: Yahoo Messenger

Re: OMXplayer - how to choose better streams with m3u8 playback?

Tue Jul 16, 2019 10:38 am

Hi Mike,

Sorry I got streamlink to work and didn't check back for a long time. I was pretty happy with that solution for a long time.

I now run into another problem, and hence I'm searching the keyword and bumped into my old question! (Can you believe it).

The problem I have with streamlink now is to play an encrypted m3u8 link but not from the beginning. I'm a subscriber of Kayo Sports, and from it, if I use Google Development tool and monitor the XHR network activity I can get the m3u8 link. But the problem is, similar to my earlier question, if you use a different program (like curl) to read the m3u8 file and then feed the link to OMXplayer, it rejects. I think there is some encryption embedded in there somewhere that forces you to use the same application/session as the original request to read the m3u8 file. That's just my guess, correct me if I'm wrong.

For live feeds, streamlink completely solved this! And that's why I was happy for the longest time. But ever since I subscribed to Kayo Sports, one of the feature it can do is allow a person to watch live stream, but that stream can be rewinded to go back 30 seconds if you miss something or such. This is not possible with streamlink. I tried the --player-passthrough tag, it didn't work because I think it passed the link to the video to omxplayer but not under the same session or used a different program, hence it didn't work like in the paragraph above.

Your player looks like a lot of work. I'm quite novice in these things. But once I can get around it, I'll give it a crack!

Thanks a lot!

User avatar
RPi_Mike
Posts: 191
Joined: Sat Dec 09, 2017 12:57 am
Location: United States

Re: OMXplayer - how to choose better streams with m3u8 playback?

Tue Jul 16, 2019 7:28 pm

henry_shadowjet wrote:
Tue Jul 16, 2019 10:38 am
The problem I have with streamlink now is to play an encrypted m3u8 link...

I've never used streamlink, so I can't give you any advice on that.

However, I will say that subscription sites have a strong incentive to make what you're trying to do either very hard or impossible. That's why I used the term "obfuscated" in my previous post from 6 months ago.

Content providers often employ specialist consulting firms with "ethical hacking" experts that deliberately try to defeat the existing protections and develop new countermeasures to play the streams on unauthorized platforms.

Why?

So they can develop even newer counter-countermeasures to plug those holes!

Without getting into the dubious ethics of what you're trying to do, that might explain why you're having such a hard time. From their standpoint, you're supposed to have a hard time — and preferably, an impossible time!

Return to “Graphics, sound and multimedia”