NodeOS / NodeOS

Lightweight operating system using Node.js as userspace

Home Page:http://node-os.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Will ffmpeg (& Linux applications) work on NodeOS?

Rob-pw opened this issue · comments

Simple question, will I be able to [install, run, interact with] software like https://github.com/FFmpeg/FFmpeg, https://github.com/rg3/youtube-dl (Python applications, C, C++, Golang) from within NodeOS?

Still depends on ffmpeg under the hood, I can use the emscripten build but this is a general question with some specific examples. On the website NodeOS describes itself as being built on Linux, is it still possible to install Linux applications underneath the NodeOS layer? (If that's how it works)

Whoops. Misunderstood. Sorry about that.

Since it's based on the Linux Kernel, NodeOS is able to execute any binary application targeted for Linux. Even if they do not allow binary software (e.g. ELF format), they might allow them compiled as .node files or even WebASM. Afaik, the LLVM devs are working on a WebASM backend, so using Clang, compiling ffmpeg to a loadable JS module should be possible and it will probably have an ok-ish performance. Though I think that it will be more than enough for anything you would like to do with NodeOS...

Since it's based on the Linux Kernel, NodeOS is able to execute any binary application targeted for Linux.

That's it, NodeOS is capable to exec regular Linux commands. In fact, the Node.js binary is a regular one, it's only that NodeOS is not focused on that, but nothing forbids to do so. You can add a musl-compiled ffmpeg binary and just drop it on your NodeOS instance, and it should work, or better than that, help to ffmpeg-fluent project to allow to bundle a ffmpeg binary or use it as a statically linked library.

Afaik, the LLVM devs are working on a WebASM backend, so using Clang, compiling ffmpeg to a loadable JS module should be possible and it will probably have an ok-ish performance.

REALLY interesting, do you have any links for that? I have been working with WebAssembly lately and seems really cool! :-D

do you have any links for that?

Official target in repository: https://llvm.org/svn/llvm-project/llvm/trunk/lib/Target/WebAssembly/

This WebAssembly backend is presently under development.
Currently the easiest way to use it is through Emscripten, which provides a
compilation environment that includes standard libraries, tools, and packaging
for producing WebAssembly applications that can run in browsers and other
environments.

Actually, it's quite old news. Back in 2015, there was a Mozilla blog post about using LLVM to compile to WebASM: https://hacks.mozilla.org/2015/12/compiling-to-webassembly-its-happening/

I am really looking forward to using Rust to compile to WebASM, because that would yield so many security guarantees and good code <3 (note: Rust uses LLVM) I am pretty sure, that many modules on npm would benefit a lot from WebASM. NodeOS will also probably be able to rewrite a few parts for better performance. Heck, the world will become a better place for performant code in the JS world!

Does currently Node.js support native execution of WebAssembly code? Maybe it would be possible to add a binary loader to the Linux kernel for WebAssembly binaries...

Chrome is a good indicator for the V8 version, from which onward a feature is supported. Check out MDN. V8 v5.7+ will support that feature. Node.JS is currently at V8 v6.0. In theory, it should be supported. However, it is difficult to find actual code examples on how to use it. Here is one from February 2017. I don't think that it is possible to load WebAssembly from the Kernel and imho it doesn't make a lot of sense. Why load WASM if you can have ELF, which is a lot more performant?

Something which definitely is possible, though, is loading Rust binary .node files into NodeJS using the Neon project. If I had to write some performance lower level code for NodeJS, I would start writing it now, making use of a Neon-wrapper and later on changing the whole thing to WASM by removing the wrapper. Though I think that the .node module would probably be more performant, because it's real binary code vs WASM AST byte-code.

I don't know (and don't care) about other platforms, but imho, Rust is the best way to go because of its security guarantees. Just making a language typed does not make it secure - at least for languages without memory management. And using current C++ features to do so is very complex and tedious.