mafintosh / peerflix

Streaming torrent client for node.js
MIT License
6.18k stars 673 forks source link

[announcement] libvlc wrapper for node.js/io.js #208

Open jaruba opened 9 years ago

jaruba commented 9 years ago

We at WebChimera believe in borderless video support for developers, as such there was clearly a need for VLC to join the wonderful world of Node.js/io.js.

Announcing WebChimera.js, a libvlc wrapper for Node.js/io.js that is extremely fast and supports overlaying HTML elements. Please make sure to read the wiki page carefully for detailed instructions.

We've also started a WebChimera.js Player project (see api docs) in an attempt to create a programmer friendly, easy-to-use HTML player for WebChimera.js

These projects are made mostly with JavaScript but are atm extremely new, we require testers for all platforms and contributors so the projects can reach maturity faster.

Screenshot of Webchimera.js Player:

@mafintosh I'm not sure if I am allowed to post announcements on the issues page and I wish no ill will but I believe these new projects are important for the peerflix/torrent-stream community and that we need it's help in order to test most use case scenarios. If you think this should not be here please feel free to close the issue. :)

Ivshti commented 9 years ago

@mafintosh I come here to shamelessly advertise.

But only because this is crazy useful and I believe this project is mad science and you might be interested.

Basically, it initializes a raw array (Uint8Array) in the JS side, and it makes libvlc draw directly into it. Then, you put this array in a texture and draw it on the screen.

It's a tiny bit less efficient than VLC, because of Chromium's (and by extension NW/Electron) multi-process architecture, where textures have to be sent through shared mem to the GPU process, and because we don't have PBO's in OpenGL ES. But it's still more efficient than most of the video players out there. I can say bravely it's production-ready.

mafintosh commented 9 years ago

@Ivshti @jaruba any good tutorials on how to use this with electron? i'd like to experiment with using this in playback

mafintosh commented 9 years ago

@jaruba also is there anyway to not require vlc being installed? can i statically embed it somehow into my electron project?

jaruba commented 9 years ago

@mafintosh

any good tutorials on how to use this with electron

is there anyway to not require vlc being installed? can i statically embed it somehow into my electron project?

Yes you can!

Just add the vlc binaries (depending on what OS you are using) in the same folder as WebChimera.js.node (if your using wcjs-player then it will be at node_modules\wcjs-player\node_modules\wcjs-renderer\node_modules\WebChimera.js\build\Release) or in the app root, i recommend using the same folder as WebChimera.js.node to not pollute your app's root folder.

VLC v2.2.1 Binaries Links:

Download VLC for Mac Download VLC for Windows Download VLC for Linux

jaruba commented 9 years ago

Also, if you don't want to use wcjs-player (demo app), you can just use wcjs-renderer (demo app) and build your own player from scratch.

Keep in mind, the Player and the Renderer have 2 different APIs:

Ivshti commented 9 years ago

@mafintosh on OS X, some symlinks are required to make embedded VLC work, so the easiest way to do it is to download our package (courtesy to @RSATom) and unzip it in the proper directory

Download: https://dl.dropboxusercontent.com/u/3810814/libvlc_2.2.1_mac.zip

And then

npm install wcjs-renderer # or wcjs-player
( cd node_modules/wcjs-renderer/node_modules/webchimera.js/build/Release; unzip -x ~/Downloads/libvlc_2.2.1_mac.zip ) # or prepend wcjs-player/node_modules/ for wcjs-player
RSATom commented 9 years ago

just little note about VLC binaries mentioned above:

But it's possible use vanilla VLC with WebChimera.js on Windows and Linux. On Mac vanilla VLC will not work due mentioned above bug

Ivshti commented 9 years ago

About the AVI fix, it is related to libvlc not detecting length of avi files over network at all, because the demuxer wants the input to be what they call FASTSEEK to read length, and the fix is in this repo: https://github.com/Ivshti/vlc-2.2. We have to make pre-build packages for WC.js + this VLC build (or original VLC build with replaced libavi_plugin), but we haven't gotten round to it.

mafintosh commented 9 years ago

this is so cool! great job guys. btw i just released prebuild yesterday if you need something for doing node prebuilds

freeall commented 9 years ago

This looks super cool! We've been talking about how we'd like something like this and now you guys did it.

RSATom commented 9 years ago

@mafintosh, @freeall Thanks! We just hoped it could be useful to community :)

Ivshti commented 9 years ago

@mafintosh @freeall we have to give you a heads up for implementing this in Playback - when a frame is rendered, wc.js calls a callback "onFrameReady" or emits event, which you have to use to render the frame through webgl (wcjs-renderer). In both cases, it relies on the JS event loop, which means if there's something blocking it, frame rendering may be delayed.

@jaruba has observed regression in Powder Player and I have in Stremio, when using WC.js with Torrent-stream. The solution is easy and provided by Electron's IPC - run torrent-stream in the main process and keep all things that can block the event loop out of the renderer process.

torrent-stream itself is very good with not blocking the event loop - but since it does a lot of memory buffer-related operations (networking, writing to FS, etc.) V8 takes a lot of time in garbage collecting and allocations, which actually blocks the main loop.

Keep in mind the way to avoid this issue is by using another process - either through node.js's fork or electron's IPC.

smolleyes commented 8 years ago

hello

don t understand how embedding vlc works ?? :p

i downloaded vlc 2.2 for linux from vlc-prebuilt github of ivshti then ? (tried to extract it aside of webchimera.js.node but i don t know if it works... (same avi bug with streams)

thanks