Git Product home page Git Product logo

p2p-media-loader's People

Contributors

antonshchemelev avatar chocobozzz avatar greenya avatar imarsv avatar jonny-gm avatar mberesnev avatar mrlika avatar tchakabam avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

p2p-media-loader's Issues

Does p2p-media-loader check segment validity?

Hi :)

I read the code, but I did not find out if p2p-media-loader was checking P2P segment validity (for example like in bittorrent with a hash function).

If it does not check them, can a peer send a fake segment?

The system doesn't show anyone else but me

Thank you for this wonderful package. But I'm having a problem. The system works perfect between two computers on the same network. I get all the video uploaded to the other computer but doesn't work for people outside the network. P2P graph always only shows me. How to fix this issue?

Wrong JWPlayer provider & General player issues

Hi, I tried to create a jwplayer instance in HLS with P2P, but it does not seem to work. In my tests the HLS is always loaded by the "provider.hlsjs.js" (default hls script of jwplayer), in the demo example i see that the segments are loaded by the initiator "p2p-media-loader-hlsjs.min.js". I can not see the difference between the test I did and the demo, could anyone explain what I did wrong?

Demo: https://jsfiddle.net/gkob21fv/1/
Browser: Chrome 70 win10

mobile peers download only

Hello,
how to configure the p2pml config that some peers (for example mobile) only download (p2p / http) ?
its possible ?
Thanks.

Highload

Yesterday i was try your script, after i was send to each webtorrent server (wss://tracker.openwebtorrent.com, wss://tracker.btorrent.xyz and wss://tracker.fastcast.nz) 5k viewers, they go down. How many messages script send to each server, that they cant do this work and go down...
Who store how many segments have peer - Server or peer ask another peers does they have segments?
Do you have goLang programmer?

Can improve support flowplayer hlsjs-lite pluglin?

This project is great, I like it very much! Thanks very much!

I use Flowplayer to play videos, but Flowplayer hlsjs plugin is deprecated and discontinued.
Flowplayer 7 help says: Your should use the hlsjs-lite plugin available in Flowplayer Core now.
Please see:
https://flowplayer.com/help/developers/flowplayer-7/setup#hlsjs-lite

I tested p2p-media-loader-hlsjs with flowplayer hlsjs-lite plugin, but play the video was easy to get stuck, can you improve this ?

Thanks very much!

Time to download chunks from peers

  1. Hi, where is param to tuning time required for full download segment from peer? Becourse segment may be 2sec of duration with 240p (100kb) and maybe 20 sec of duration with 4k video (10Mb), what param tune it in script to cancel slow downloads from peer and use CDN for this segment? If peer one canceled it will be used on next segment download?
  2. if some bytes was loaded from slow peer and this downloaded was canceled, will script use Range request to download from CDN rest of file, or will download full segment?

make new release

Lots of improvement has happened since last time, could you make a new release maybe?

A way that can improvement this library

One improvement that can be made is to force the player to start downloading and playing the first segment instead of the last one or the one before.
That can lead to latency problems but that's not a big issue i guess , if the playlist have 6 segments, 10 seconds each, if you force the player to start from the first segment, that gives the P2P-media-loader enough time (50 seconds) to download the rest segments through P2P, instead of downloading the last one or the one before (gives the library 10 to 20 seconds to download the next segment through P2P).
there is no way to do that in Clappr as i know, the only work around i found is to seek back he first segment like this:

events: {
                    onPlay: function() {
                    if (player._hasSeek) {
                        return
                    }
                    player.seek(0);
                    player._hasSeek = true;
                    },
                } 

i don't know about other players, i hope there are a way to force the player to download and play the first segment. and add that option to this library so we can configure what segment that can be download first. so if latency is important to someone then he can choose the last segment, and if it's not an issue he can choose the first one and give enough time to P2P-media-loader to download the max segments through P2P.
thanks a lot for this amazing library

Shaka buffering frequently after using the loader

Hello, I don't know how to explain this issue very well.
I using this loader on VOD with 720/1080 videos, where segments usually ~10MB for 720 and ~20MB for 1080.
Without the loader, segments can be downloaded very fast via CDN
I am wondering if my current configuration is not suitable for VOD?

Also, I noticed the P2P request sequence seem to not ordered.
For example, say current segment is 100, next segment will be 101, but we got 102 instead, so we need to wait for 101 to load.
Maybe this cause the playback stucks frequently?

My current configuration:

{
        loader: {
          cachedSegmentsCount: 75,
          cachedSegmentExpiration: 1000 * 60 * 15,
          simultaneousP2PDownloads: 4,
          httpDownloadProbability: 0.05,
          httpDownloadProbabilityInterval: 1000,
          bufferedSegmentsCount,
          trackerAnnounce: ['wss://tracker.openwebtorrent.com', 'wss://tracker.fastcast.nz'],
        },
        segments: {
          forwardSegmentCount: bufferedSegmentsCount,
          maxHistorySegments: 0,
        },
}

Segments relative links with dots

Hello,

Thanks for your library!

But I have segment links that look like this:

#EXTINF:20.000,
./big_buck_bunny.mp4:hls:seg-1-v1-a1.ts
#EXTINF:20.000,
./big_buck_bunny.mp4:hls:seg-2-v1-a1.ts
#EXTINF:20.000,
./big_buck_bunny.mp4:hls:seg-3-v1-a1.ts

And it seems that the library can't handle these "./" at the start of each link, and as a result, p2p does not work.
(engine.loader.segments is empty while Playlist.segments is not)

Option `port` is required for the tracker client

Although the "bittorrent-tracker (client.js)" documentation states that the "port" argument is optional, in fact it is mandatory.

webtorrent/bittorrent-tracker#315

This is causing the following error here:

Uncaught (in promise) Error: Option `port` is required
    at new Client (F: \ NWJS_SDK \ package.nw \ node_modules \ bittorrent-tracker \ client.js: 45)
    at P2PMediaManager.createClient (F: \ NWJS_SDK \ package.nw \ node_modules \ p2p-media-loader-core \ dist \ p2p-media-manager.js: 201)
    at P2PMediaManager. <anonymous> (F: \ NWJS_SDK \ package.nw \ node_modules \ p2p-media-loader-core \ dist \ p2p-media-manager.js: 187)
    at Generator.next (<anonymous>)
    at F: \ NWJS_SDK \ package.nw \ node_modules \ p2p-media-loader-core \ dist \ p2p-media-manager.js: 22
    at new Promise (<anonymous>)
    at __awaiter (F: \ NWJS_SDK \ package.nw \ node_modules \ p2p-media-loader-core \ dist \ p2p-media-manager.js: 18)
    at P2PMediaManager.setSwarmId (F: \ NWJS_SDK \ package.nw \ node_modules \ p2p-media-loader-core \ dist \ p2p-media-manager.js: 169)
    at HybridLoader.load (F: \ NWJS_SDK \ package.nw \ node_modules \ p2p-media-loader-core \ dist \ hybrid-loader.js: 104)
    at Object.self.fetch (assets / js / utils / prx.js: 306)

Peer Segment Download Timeout

Hello,

I see that sometimes peers can't upload in high speeds.

In this case if reciever encounter this type of peer It starts to wait until the downloading segment from slow connection peer complete. But when player reaches that segment, Its just freezes and waiting the segment download finish.

So my question is;

  1. p2pSegmentDownloadTimeout represents downloading timeout or connection timeout?
  2. If Its connection timeout, Is there any way to set downloading timeout?

I've try to set p2pSegmentDownloadTimeout to 5000 but It didn't solve the issue.

Player loads segments out of order and stops

When I run VOD HLS, the player loads the manifest segments in a different order. If the next segment is not loaded, the player stops.

This is what the Network tab in chrome displays:
..._3.ts
..._4.ts
..._20.ts
..._5.ts
..._10.ts
..._6.ts
..._7.ts
..._19.ts

At this point, the player stopped, because the 8th segment did not have time to load. Further, the player does not load any segments, the video stops playing.

This error occurs even on your demo, if you put a link to VOD HLS:
http://novage.com.ua/p2p-media-loader/demo.html?url=https%3A%2F%2Fwowza.peer5.com%2Fvod%2Fsmil%3Abbb_abr.smil%2Fplaylist.m3u8&type=jwplayer

My browser is Chrome 72.0.3626.121

Can you please add some download and upload to the demos ?

Can you please add something that shows how much download and upload every peer made to the other demos ( like this demo ) without graphs, a simple div that got updated every 5 seconds for example would be helpful.
because even if you enable debugging there are lot of informations, where sometimes you want just to see the performance ( p2p download vs http download ).
thanks for the great library

Installation

Hey mrlika & team,

is there an detailed instruction, how to install p2p-media-loader on an windows root/dedicated server? We want to test it in our own environment.

Keep up the good work ;)

using custom tracker server

I'm using bittorrent-tracker with the following code

var Server = require('bittorrent-tracker').Server

var server = new Server({
  udp: false, // enable udp server? [default=true]
  http: false, // enable http server? [default=true]
  ws: true, // enable websocket server? [default=true]
  stats: true, // enable web-based statistics? [default=true]
  filter: null
})

server.ws

server.on('error', function(err) {
  // fatal server error!
  console.log(err.message)
})

server.on('warning', function(err) {
  // client sent bad data. probably not a problem, just a buggy client.
  console.log(err.message)
})

server.on('listening', function() {
  console.log('listening on ws port:' + server.ws.address().port)
})

// start tracker server listening! Use 0 to listen on a random free port.
var port = 8080,
  hostname = "localhost";
server.listen(port, hostname)

// listen for individual tracker messages from peers:

server.on('start', function(addr) {
  console.log('got start message from ' + addr)
})

server.on('complete', function(addr) {})
server.on('update', function(addr) {})
server.on('stop', function(addr) {})

then open url

http://novage.com.ua/p2p-media-loader/demo.html?url=https%3A%2F%2Fwowza.peer5.com%2Flive%2Fsmil%3Abbb_abr.smil%2Fchunklist_w1374448516_b591000.m3u8&type=clappr&trackers=ws://localhost:8080

in CMD I can see

got start message from 324d592d8855ff28e04c66a20fde7de68972d170

but I cannot see P2P traffic in stats, can you please create example working code for the server.

Thanks

Not work when WebRTC IP disabled

I use Chrome extension uBlock Origin, by default the option for Privacy > Prevent WebRTC from leaking local IP addresses is enabled, when this option enabled in console I see websocket is connected and no error but cannot find another peer, It is required to use WebRTC IP?

Optimizing settings for VOD

Hello, thank you so much for creating and maintaining this amazing plugin!

I am currently integrating with the Shaka Player, I don't really understand how these settings works as they looks so identical:

  • segments: forwardSegmentCount
  • segments: maxHistorySegments
  • loader: cachedSegmentsCount
  • loader: bufferedSegmentsCount

Any clarification would be really helpful.

Multiple CDNs for identical stream

I currently have my broadcast on multiple servers, and do a simple client-side random to decide what source to use in that client's player.
Would it be possible to have the same peer network for all CDNs? Does this happen automatically based on the hash of the files? If not, is there some way to have control over this?

Thanks in advance.

UDP Torrent tracker

Hi there Nice project. Im tring to use it with a different tracker , but managed to make it work just with bittorrent-tracker, there is a way to Use it with UDP or to change it to Another tracker on WSS..

short history im tring to use a tracker to oprtimize

Increasing The Peer Ratio

Hello,

How can we increase peer ratio? Any specific way like more tracker server or changing some config etc.

For me currently only %20 of my streams goes over peer traffic. Other %80 still loading from servers. When I was using peer5 this ratio was around %40-%50.

Thanks to you I have my own peer network now 🥇 💯 👍

But I wanted to know if its possible to improve performance or not.

Thanks :)

Lag in playing VOD stream over ExoPlayer.

I have made a tiny wrapper utilising P2P media loader HLS package to be consumed in an Android App. There's 2 things i was wondering if someone can help me cross verify.

  1. In context to HLS.js, setPlayingSegment, is being called on a HLS.JS event i.e. hlsFragChanged.

Likewise in exoplayer i'm tad-bit confused which event would call this. RIght now i'm using onLoadCompleted. Not sure if setPlayingSegment is to be called when frame is requested or responded.

  1. Everything seems to work great except sometimes Media packets (.ts) on successSegment, could take awhile to resolve and resulting in loadError inside ExoPlayer as well as more bufferring than expected. ExoPlayer does try to play it by downgrading the resolution though at somepoint later in sequence ends up hanging up because of sourceError.

One of the solutions i'm tried today was to read chunk list and request for packets ahead of time and keep track of it so when player requests it i can directly resolve it. Though i get this error, Cancel segment request: simultaneous segment requests are not supported.

Just wanted to run it through @mrlika if you have more ideas. Also kudos on library. Lemme know if there's anything i can help with. By now i'm very close to finish reading almost your entire source code to make it work over android.

P.s.: I know i'mma not have a perfect solution (hacky solution ofcourse 😏) just wanted todo a POC that p2p between web+android is possible using webrtc. I think peer5 does same underhood.

Fallback to

Hello,

Is it possible to make a fallback to normal palyer when p2p is not possible?

On IE or Edge, It just gives error and video is not playable.

this.peer.on is not a function

Testing here I ended up getting stuck here on line 42 of the media-peer.js:

class MediaPeer extends stringly_typed_event_emitter_1.default {
    constructor (peer, settings) {
        super();
        this.peer = peer;
        this.settings = settings;
        this.remoteAddress = "";
        this.downloadingSegmentId = null;
        this.downloadingSegment = null;
        this.segmentsMap = new Map ();
        this.debug = Debug ("p2pml: media-peer");
        this.timer = null;
        //! at this point this.peer (peer too) here is a string like "179.187.29.127:9736", not an object
        this.peer.on ("connect", () => this.onPeerConnect ());

=>

Uncaught TypeError: this.peer.on is not a function
    at new MediaPeer (/home/efox/Downloads/nwjs-sdk-v0.35.4-linux-x64/package.nw/other_modules/p2p-media-loader-core/dist/media-peer.js:54)
    at P2PMediaManager.onTrackerPeer (/home/efox/Downloads/nwjs-sdk-v0.35.4-linux-x64/package.nw/other_modules/p2p-media-loader-core/dist/p2p-media-manager.js:217)
    at Client.emit (events.js: 188)
    at /home/efox/Downloads/nwjs-sdk-v0.35.4-linux-x64/package.nw/node_modules/bittorrent-tracker/lib/client/http-tracker.js:208
    at Array.forEach (<anonymous>)
    at HTTPTracker._onAnnounceResponse (/home/efox/Downloads/nwjs-sdk-v0.35.4-linux-x64/package.nw/node_modules/bittorrent-tracker/lib/client/http-tracker.js:207)
    at /home/efox/Downloads/nwjs-sdk-v0.35.4-linux-x64/package.nw/node_modules/bittorrent-tracker/lib/client/http-tracker.js:60
    at onResponse (/home/efox/Downloads/nwjs-sdk-v0.35.4-linux-x64/package.nw/node_modules/bittorrent-tracker/lib/client/http-tracker.js:177)
    at concat (/home/efox/Downloads/nwjs-sdk-v0.35.4-linux-x64/package.nw/node_modules/bittorrent-tracker/node_modules/simple-get/index.js:89)
    at IncomingMessage. <anonymous> (/home/efox/Downloads/nwjs-sdk-v0.35.4-linux-x64/package.nw/node_modules/simple-concat/index.js:7)

What could be the cause for the peer variable to be a string and not an object?

Why does it not work on safari ios?

Why is it not possible to deliver hls to ios devices?
They do support WebRTC Data Channels and I don't really understand what's the problem.
I also think that peer5 is able deliver hls to ios devices vie peer to peer but I wasn't able to figure out how.
Is it pollible to do so and just not supported by this p2p-media-loader or is it impossible to deliver hls to ios devices over WebRtc?

check amount downloaded

Hi there, it is any way to have the amount of segments downloaded by p2p and the amount by HTTP
Or whatever stats of traffic to check

Thanks in advance

404 .ts segment

Hi
when .ts segment is loading it get 404 error sometimes.
What is the reason ?
How to fix it or config something ?

[Question] What is best config ratio for httpDownloadProbability?

I just wonder why default config look like this:

httpDownloadProbability: 0.06,    
httpDownloadProbabilityInterval: 500,

As i understand, when processSegmentsQueue trigger, its used httpDownloadProbability to random downloading through http. So with 0.06 ratio, after 20 times ~ 10 secs, all segment queued will download through http? Is it too short?
If i set httpDownloadProbability: 0, does p2p rate would be down?
Thanks.

Quality Change

Hello,

Would it be possible to let users choose the quality without breaking the p2p structure?

I'm using this one with notmal HLS streaming. But Its not compatible with your p2p script.

Segment Identification

Hello,

First of all, thanks for this awesome open source.

My m3u8 file url and all segments links are different for each user.

I believe peer system is identify which peer connect to which by segment or m3u8 links. But its not able to do it correctly because all users got a different m3u8 and segment links.

Is there any way to make a manuel match?

Something like this;

fileLinkReplace: function (url) {
   url = remove_unique_parts(url);
   return url;
}
segmentIdReplace: function (level, sn, url) {
   url = remove_unique_parts(url);
   return url;
}

from

https://example.com/hls/baxppq2zn5ts5n2gmlloot52i6lyz5rcvhjiszq4vsemf5jdqxwulk7bcxha/seg-27-v1-a1.ts

to

https://example.com/hls/videoid352352/seg-27-v1-a1.ts

Hls.js/clappr Stopped working, also basic usage example

So, viewing the demo example on the novage site runs as expected, however when i take the clappr example from here:

No p2p action happens. it gets this far, and then nothing more. No attempts on a websocket connection or any relevant debug logs:
p2pml:hybrid-loader loader settings +0ms Object p2p-media-loader-core.min.js:25 p2pml:p2p-media-manager peer ID +0ms 629918747b9e2edd7c1b36e713174b339446c714

Its a bit of an odd one, i previously had this working in a much more complicated setup and then today it stopped functioning, even in this simplified example.

The same is happening in both FF and Chrome latest on mac and windows, for me at least.

Is anyone able to reproduce this bug?

Function download Range not working

Hi All,

I want download range but it not woking with me

request.setRequestHeader("Range", segment.range);

segment.range is undefined

my file .m3u8 and server support download range

#EXTM3U
#EXT-X-VERSION:4
#EXT-X-TARGETDURATION:11
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-PLAYLIST-TYPE:VOD
#EXTINF:8.217089,
#EXT-X-BYTERANGE:212440@0
5bd9fd91ce7e1b08435acb87-000.ts
#EXTINF:10.427778,
#EXT-X-BYTERANGE:2814360@212440
5bd9fd91ce7e1b08435acb87-000.ts
#EXTINF:2.794644,
#EXT-X-BYTERANGE:128592@3026800
5bd9fd91ce7e1b08435acb87-000.ts
..........

image

wrong url of segments if m3u8 was redirected

hi, if m3u8 src is

server.com/redirector.php?video.m3u8

and it redirect to

storage.com/hash/video.m3u8

script download m3u8 successfuly, after that try download ts files from server.com, but should from storage.com/hash/

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.