Improve html5 live video streaming

13 réponses [Dernière contribution]
GNUser
Hors ligne
A rejoint: 07/17/2013

Hello everyone,

So, when I watch real-time live video streams on the browser, sometimes I get too many pauses (I am unsure if it's caused by the server having too many people watching, or if it is my connection that is too slow to download fast enough). Anyway, it's normal for me to every couple minutes have a pause of a few seconds for the video to load again and keep playing. I would like to try and find a way to "cache" more of the video before playing, meaning I don't mind watching the video a few seconds later, or even a few minutes, if that meant watching without interruptions. However I am unsure how to do it in Firefox (or derivatives, Abrowser, Icecat, etc). Anything I might change in about:config that will do what I want?

Thanks.

Narcis Garcia
Hors ligne
A rejoint: 04/15/2019

I don't know about tweaking that stream preload parameter, but think
that you have the option to download the video file and play it offline.

El 30/8/19 a les 14:23, name at domain ha escrit:
> Hello everyone,
>
> So, when I watch real-time live video streams on the browser, sometimes
> I get too many pauses (I am unsure if it's caused by the server having
> too many people watching, or if it is my connection that is too slow to
> download fast enough). Anyway, it's normal for me to every couple
> minutes have a pause of a few seconds for the video to load again and
> keep playing. I would like to try and find a way to "cache" more of the
> video before playing, meaning I don't mind watching the video a few
> seconds later, or even a few minutes, if that meant watching without
> interruptions. However I am unsure how to do it in Firefox (or
> derivatives, Abrowser, Icecat, etc). Anything I might change in
> about:config that will do what I want?
>
> Thanks.

GNUser
Hors ligne
A rejoint: 07/17/2013

I can't because it's not a single video file. It's a constant stream. In html5 player the right click doesn't show the option to "save video".

chaosmonk

I am a member!

I am a translator!

Hors ligne
A rejoint: 07/07/2017

> I can't because it's not a single video file. It's a constant stream. In
> html5 player the right click doesn't show the option to "save video".

Can you link to an example?

GNUser
Hors ligne
A rejoint: 07/17/2013

https://sportbar.biz/sk2serbia.html

I believe it requires JS though. Sorry :(

chaosmonk

I am a member!

I am a translator!

Hors ligne
A rejoint: 07/07/2017

> https://sportbar.biz/sk2serbia.html
>
> I believe it requires JS though. Sorry :(

By viewing the page source I found this line:

var videoLink = 'https://sportbar.biz/lba/ZmJkYmU0M2M1NTk0ZTdiMGViYzE4ODE0NWZiMTUyNjY=/g3/sk2serbia.m3u8?token=ZmJkYmU0M2M1NTk0ZTdiMGViYzE4ODE0NWZiMTUyNjY=&id=MWM2OWEyZGE4MDAzMGI3NDVkZjdhYTJhOWQ2YWRkZjg=&vip=1567178367&dip=NjUxYzhmNTk4N2EwMzVmMWQwNDI4ODBmOGRjMmI5ZmI=&pip=31.7.59.226&hip=ZDYzMjA2ODRjYjI3NzI0ZTE2MzU4NDk5N2NhZDk4ZGQ=';

I tried playing the link with

$ mpv https://sportbar.biz/lba/ZmJkYmU0M2M1NTk0ZTdiMGViYzE4ODE0NWZiMTUyNjY=/g3/sk2serbia.m3u8?token=ZmJkYmU0M2M1NTk0ZTdiMGViYzE4ODE0NWZiMTUyNjY=&id=MWM2OWEyZGE4MDAzMGI3NDVkZjdhYT...

and it worked, but kept freezing. So this solves the JS problem, but not
your original problem.

I then ran

$ youtube-dl --list-formats https://sportbar.biz/lba/ZmJkYmU0M2M1NTk0ZTdiMGViYzE4ODE0NWZiMTUyNjY=/g3/sk2serbia.m3u8?token=ZmJkYmU0M2M1NTk0ZTdiMGViYzE4ODE0NWZiMTUyNjY=&id=MWM2OWEyZGE4MDAzMGI3NDVkZjdhYT...

and got

[info] Available formats for sk2serbia:
format code extension resolution note
0 mp4 unknown

To capture the stream as an mp4 file, I then ran

$ youtube-dl --format 0 https://sportbar.biz/lba/ZmJkYmU0M2M1NTk0ZTdiMGViYzE4ODE0NWZiMTUyNjY=/g3/sk2serbia.m3u8?token=ZmJkYmU0M2M1NTk0ZTdiMGViYzE4ODE0NWZiMTUyNjY=&id=MWM2OWEyZGE4MDAzMGI3NDVkZjdhYT...

(Since there was only one format available, it might not have been
necessary to specify the format with "--format")

I let this run for a while, and saw that it created
"sk2serbia-sk2serbia.mp4.part" in the working directory. I renamed it to
"sk2serbia-sk2serbia.mp4" and tried to play it with mpv and... it didn't
work.

$ mpv sk2serbia-sk2serbia.mp4
Playing: sk2serbia-sk2serbia.mp4
[ffmpeg/demuxer] mov,mp4,m4a,3gp,3g2,mj2: moov atom not found
[lavf] avformat_open_input() failed
[ffmpeg/demuxer] mov,mp4,m4a,3gp,3g2,mj2: moov atom not found
[lavf] avformat_open_input() failed
Failed to recognize file format.

If I have time later I'll see if I can make more progress.

GNUser
Hors ligne
A rejoint: 07/17/2013

First, thanks for all the work. I always appreciate the effort you put into helping others here in the forum! Thanks!

Second, I have already (a few months ago) tried doing that. BUT, let's take in consideration I usually have different links and different websites, so there is little point in doing it with scripts and command line and source code... Each time things will be different. The best chance I have is to make Abrowser/Icecat/Firefox/TorBrowser work best playing the live stream with the html5 (or even the JS player).

Which makes me wonder again... is there any configuration I can make load more of the streams before initiating playback?

Thanks.

chaosmonk

I am a member!

I am a translator!

Hors ligne
A rejoint: 07/07/2017

> The best chance I have is to make Abrowser/Icecat/Firefox/TorBrowser
> work best playing the live stream with the html5 (or even the JS
> player).
>
> Which makes me wonder again... is there any configuration I can make
> load more of the streams before initiating playback?
>
> Thanks.

I don't think this video is embedded with HTML5. I don't see a video tag
anywhere in the source. The only place the videolink variable is used is

player = new Playerjs({id:"videoplayerdiv", file:videoLink, auto:"play"});

when I guess is defined here.[1]

I'm not sure how you'd go about finding a one-size-fits-all solution
that works on all sites that provide their own JS player. Even if you
find a way to modify the JS player on this site to load more of the
stream, it wouldn't work on another site that uses a different JS
player.

[1] https://static.sportbar.biz/playerjs.js

GNUser
Hors ligne
A rejoint: 07/17/2013

You are right of course. But I would think that Firefox must have it's own caching settings, or am I wrong on this one?

chaosmonk

I am a member!

I am a translator!

Hors ligne
A rejoint: 07/07/2017

> You are right of course. But I would think that Firefox must have it's
> own caching settings, or am I wrong on this one?

I think J.B. Nicholas is right, and that Firefox's settings probably
can't affect the behavior of the JS player provided by the website.
Firefox can't modify the behavior of an arbitrary JavaScript program.

J.B. Nicholson-Owens
Hors ligne
A rejoint: 06/09/2014

name at domain wrote:
> https://sportbar.biz/sk2serbia.html
>
> I believe it requires JS though. Sorry :(

That might be your problem -- unlike linking to a WebM video using the
VIDEO HTML5 element, a custom player (like what I'm guessing is involved in
one of those JS files) can use whatever caching details the developer
wants. The browser's configuration (such as Firefox's about:config
settings) might play no role in determining how much data you download
before playback begins.

If this video stream were instead handled with an HTML5 VIDEO element (this
could be live video or a recorded stream; what the browser really wants is
data in a format it can play), you'd be in more control of playback and the
browser configuration details could matter more.

aloniv

I am a translator!

Hors ligne
A rejoint: 01/11/2011

Try watching/downloading it using streamlink. Streamlink supports multiple connections (in this example I used 8) which can prevent buffering:
streamlink --loglevel debug --hls-segment-threads 8 --hls-segment-timeout 100 --hls-timeout 600 --hls-playlist-reload-attempts 10 --hls-live-edge 3 'https://sportbar.biz/lba/MGJiNzBiYjk4ZDdlNzkxNWJjNzNiNDFlNTYxOGIwZDI=/g3/sk2serbia.m3u8?token=MGJiNzBiYjk4ZDdlNzkxNWJjNzNiNDFlNTYxOGIwZDI=' worst -o file.flv

GNUser
Hors ligne
A rejoint: 07/17/2013

Thank you. I didn't know about streamlink, and for now I have an alternate solution, but it seems interesting (is capable of using Tor or I2P as for proxy, which is good, and support many different kinds of links).

I will keep it in memory for a need case. Thanks.

aloniv

I am a translator!

Hors ligne
A rejoint: 01/11/2011

streamlink is a new fork of livestreamer which can be found in the repos.