Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upI made a createServer equivalent for browsers #1522
Comments
This comment has been minimized.
This comment has been minimized.
|
It's similar to how my StreamSaver lib works... |
This comment has been minimized.
This comment has been minimized.
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
This comment has been minimized.
This comment has been minimized.
|
Hadn't seen this, it's a really nice experiment. Do you maybe want to submit it to the list of things built with WebTorrent? |
This comment has been minimized.
This comment has been minimized.
Nah, it's not even a "thing" (so called project, module or a service) just a experiment as you said. (PoC) What I perhaps would like to see is if it would be worth considering implementing this somehow maybe even replace the existing way of how media is played/streamed today. The benefit of my method is that you will take off lots of work from the main thread, keeping the main thread more responsive. You will also get more support for other containers like webm, mp4, ogg etc out of the box. You would be able to get rid of this packages then:
what i have built is just a proof of concept... so it's not really a plug and play thing that you can add to webtorrent to make it work out of the box |
This comment has been minimized.
This comment has been minimized.
|
IMHO i think videostream and render-media and all of that is out of the scope of webtorrent. So I think that should be removed. it's not necessary for sharing things p2p But serving the files in a streaming fashion from the torrent client isn't and that is what createServer is doing. and it just so happen to support streaming videos as well |
This comment has been minimized.
This comment has been minimized.
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
This comment has been minimized.
This comment has been minimized.
|
Its great idea Jimmy, have you tested it for streaming? |
This comment has been minimized.
This comment has been minimized.
after that it's as simple as just adding video.src = `./webtorrent/${torrent.infoHash}/${torrent.files[5].path}`
Did you even bother looking in the repo for demo and some code? There is not much else going on in that repo like compiling and doing other unrelated things. Looking at 3 files is not much. the browser handles the seeking. When you seek it will make a partial request and map that to the byte offset that it needs to download |
This comment has been minimized.
This comment has been minimized.
|
Like mention earlier: it's just a PoC not some pluggable plugin you can just add since you need to configure a service worker and it patches WebTorrent. The idea was to showcase that
... so that i could catch somebody's attention/interest and work towards implementing something like this into webtorrent itself |
This comment has been minimized.
This comment has been minimized.
|
if there where maybe one thing i would have changed about this old code is that i would have used transferable streams instead of using MessageChannel |
This comment has been minimized.
This comment has been minimized.
|
I'm surprized ferros never commented on this, Its really like to know how does hi thinks about it? |
This comment has been minimized.
This comment has been minimized.
@feross wants to have it in a service worker but it is currently not possible since service worker are sort lived and don't have WebRTC. It's possible to work around it by using eg transferable-readable-whatwg-streams (or just messageChannel) and pipe it to a
for reasons stated above
I'm working on a fork of webtorrent and many submoddules that is stripped down to only work in the browser. it's more lightweight and somewhat faster. (less prone to browser freeze, use less memory and CPU) works both in main thread and inside service worker - it has this kind of built in "server" to give all chunks directly from indexedDB directly instead of asking main thread for them, weights in at around ~100kb something (still very much in developing stage for now) i wonder if he would wants to collaborate on some submodules i have created. |
This comment has been minimized.
This comment has been minimized.
|
Nice, thanks for your answer, although this was too technical for me to completely understand, but it feels like good things are going to happen, I'm not familiar with browser service worker, but Im wondering if the videostream package is doing anything special that if we lose that anything bad happens? |
With the power of service worker:
https://github.com/jimmywarting/webtorrent-server-browser
Have a look if it's something of an intresse
the catch is you need to have the main window running to pipe a file stream to the service worker.
Would ofc be better if the service worker where able to read directly from say indexedDB or some storage layer and wouldn't need to communicate thought postMessage