Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jaruba opened this issue Jun 6, 2015 · 13 comments
Open

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

jaruba opened this issue Jun 6, 2015 · 13 comments

Comments

@jaruba
Copy link

jaruba commented Jun 6, 2015

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
Copy link
Contributor

Ivshti commented Jun 6, 2015

@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
Copy link
Owner

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

@mafintosh
Copy link
Owner

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

@jaruba
Copy link
Author

jaruba commented Jul 26, 2015

@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
Copy link
Author

jaruba commented Jul 27, 2015

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
Copy link
Contributor

Ivshti commented Jul 27, 2015

@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
Copy link

RSATom commented Jul 27, 2015

just little note about VLC binaries mentioned above:

  • VLC for Mac - it contains same modules as original VLC.dmg but a little bit rearranged to workaround bug with plugins loading introduced in VLC 2.2.x (only Mac version affected)
  • VLC for Win - it contains the same modules as in http://www.videolan.org/vlc/download-windows.html except modified libavi_plugin.dll (to fix show video time when it played over network)

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
Copy link
Contributor

Ivshti commented Jul 27, 2015

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
Copy link
Owner

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

@freeall
Copy link

freeall commented Jul 27, 2015

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

@RSATom
Copy link

RSATom commented Jul 27, 2015

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

@Ivshti
Copy link
Contributor

Ivshti commented Jul 27, 2015

@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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants