WebTorrentPlayer is a high performance player module for your next WebTorrent based project, it works around all the gotchas with WebTorrent when working with any sort of video files. It also fully supports streaming in all it's features.
General motivation is to get rid of all duplicate RAM usage and reduce CPU usage, provide better/working alternatives for existing WebTorrent functionality, and provide any features you'd see in a modern video player, ex: YouTube's.
npm install https://github.com/ThaUnknown/webtorrent-player
Then
import WebTorrentPlayer from 'webtorrent-player'
new WebTorrentPlayer({ opts })
Or you can include the bundle file [see index.html for an example]
Note: the user needs to include the /sw.js
and /lib/subtitles-octopus-worker.*
since they are imported externally by the browser when registering workers.
* more information below
Firefox is bad. I mean, it's good as a browser, but it clearly doesn't want to support webapps, so a lot of firefox functionality is limited, for example it only allows IDB files up to 2.14GB meaing you will end up using a lot more RAM, doesn't support threaded canvas rendering etc.
WebTorrentPlayer uses the browser's built in video player [thanks to jimmywarting for this idea] to play back files, this means playback support is browser dependent
Containers | Chromium | Mobile Chromium | Edge Chromium | Firefox |
---|---|---|---|---|
3g2 | ✓ | ✓ | ✓ | ✓ |
3gp | ✓ | ✓ | ✓ | ✘ |
avi | ✘ | ✘ | ✘ | ✘ |
m2ts | ✘ | ✘ | ✓** | ✘ |
m4v etc. | ✓* | ✓* | ✓* | ✓* |
mp4 | ✓ | ✓ | ✓ | ✓ |
mpeg | ✘ | ✘ | ✘ | ✘ |
mov | ✓ | ✓ | ✓ | ✓ |
ogm ogv | ✓ | ✓ | ✓ | ✓ |
webm | ✓ | ✓ | ✓ | ✓ |
mkv | ✓ | ✓ | ✓ | ✘ |
* Container might be supported, but the container's codecs might not be.
** Documented as working, but can't reproduce.
Full list of all tested video extensions:
.3g2 .3gp .asf .avi .dv .flv .gxf .m2ts .m4a .m4b .m4p .m4r .m4v .mkv .mov .mp4 .mpd .mpeg .mpg .mxf .nut .ogm .ogv .swf .ts .vob .webm .wmv .wtv
Are any missing?
Video Codecs | Chromium | Mobile Chromium | Edge Chromium | Firefox |
---|---|---|---|---|
AV1 | ✓ | ✓ | ✓ | ✓ |
H.263 | ✘ | ✘ | ✘ | ✘ |
H.264 | ✓ | ✓ | ✓ | ✓ |
H.265 | ✘ | ✘ | ✓* | ✘ |
MPEG-2/4 | ✘ | ✘ | ✘ | ✘ |
Theora | ✓ | ✘ | ✓ | ✓ |
VP8/9 | ✓ | ✓ | ✓ | ✓ |
* Requires MSStore extension which you can get by opening this link ms-windows-store://pdp/?ProductId=9n4wgh0z6vhq
while using Edge.
Audio Codecs | Chromium | Mobile Chromium | Edge Chromium | Firefox |
---|---|---|---|---|
AAC | ✓ | ✓ | ✓ | ✓ |
AC3 | ✘ | ✘ | ✓ | ✘ |
DTS | ✘ | ✘ | ✘ | ✘ |
EAC3 | ✘ | ✘ | ✓ | ✘ |
FLAC | ✓ | ✓* | ✓ | ✓ |
MP3 | ✓ | ✓ | ✓ | ✓ |
Opus | ✓ | ✓ | ✓ | ✓ |
TrueHD | ✘ | ✘ | ✘ | ✘ |
Vorbis | ✓ | ✓ | ✓ | ✓* |
* Might not work in some video containers.
Multi-audio tracks is only supported in after enabling flags:
chrome://flags/#enable-experimental-web-platform-features
media.track.enabled
Offline storage also uses IDB which on Firefox has a 2.14GB limit, meaning you can't actually offline store all that much when using Firefox, this isn't an issue on any Chromium browser.
This feature allows you to download torrents across multiple sessions, and even play them back without any internet connection.