Giter Site home page Giter Site logo

live-torrent's Introduction

live-torrent

Build Status

ex

Simple proof-of-concept for a live streaming solution based on webtorrent. Video player courtesy of hls.js.

Demo

Yes please ! Live demo with sintel at live.computer

Run it yourself

# Install
npm i -g live-torrent

# Start with example live-feed
live-torrent -v -u https://live.computer/manifest.m3u8

# ... or Create a Webtorrent enabled feed from a folder with .ts files
live-torrent -v -l -f feed

# Open browser at http://127.0.0.1:8008

FAQ

I have a regular feed already

live-torrent can convert your feed into a webtorrent enabled feed. The first example command above will download the feed at https://live.computer/manifest.m3u8, and generate a webtorrent-enabled HLS feed from it. Just open your web-browser at http://127.0.0.1:8008 to have a look.

I want to create a feed !

No problem - the second example up here will generate a feed for the directory feed, how simple ! New chunks added to the directory will be pushed to the manifest.

Have a look in the feed directory for instructions on how to generate a sample feed from a mp4 file.

How to implement on a website ?

Just host the script, serviceworker and videoplayer on your site and you're good to go. Also, there are some limitations to the use of SW ; the site hosting the videoplayer needs to be served from HTTPS, and serviceworker should be located at the root of the domain (e.g. https://live.computer/sw.js). Also feel free to open an issue if something's acting weird :)

Do I need CORS ?

Yes ! But it's easy to enable. It's enabled by default using the "create from a folder" option.

How is it working ?

TLDR(ish); A server script parses the video manifest and generates torrent magnet links from the video chunks. The magnets are pushed on the manifest.

Now on the browser side, the videoplayer downloads the manifest, the serviceworker hijacks the request, extracts the magnet links, and tries to download the chunks via webtorrent. If it fails, it falls back to the manifest url (and then seed), otherwise, well p2p - yay !

Basically 3 different pieces are needed :

  1. a server script to make a HLS manifest with magnet links in it
  2. serviceworker to proxy the manifest/chunks requests
  3. client script, that's the bit utilizing webtorrent (no webrtc in SW !)

TODO:

  • Implement CLI tool that could live on top of existing feeds
  • Optimise p2p - shave off more time for webtorrent to download the chunks

live-torrent's People

Contributors

pldubouilh avatar

Watchers

James Cloos avatar

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.