Can electron apps play any videos supported locally? - node.js

I'm aware that browsers usually restrict players to mp4 and webm type of media, but I'm wondering if it's possible for an electron-based app to run local videos with formats such as MKV and AVI. I can't find a definite source telling me what is and what is not available.

Electron is still limited to web technologies...
This means even though you have access to the file system and whatnot through the node APIs, content rendering happens inside a BrowserWindow which has about the same support for video playback as webkit based browsers.
You can use HTML5 video or canvas for this purpose, and that's pretty much it natively. (Flash is theoretically also supported, but the amount of work required to get it running is not worth it in my opinion... also, it's Flash, so, no.)
... but that's not entirely true
Even though native support ends there, you have various paths you can take to work around these limitaions. I'll list a few of the most common ones:
Convert your MKV/AVI video in the background to one of the supported formats. This has the drawback of needing the entire video file to be present on your filesystem (i.e doesn't work for streams).
Transcode your MKV/AVI stream on the fly to a supported format. This is pretty flexible but has some serious requirements on your environment, like having ffmpeg (or something similar) installed locally. Good luck packaging that if you want to distribute your app.
Embed a player capable of MKV/AVI playback. Most common example is VLC Player embedded through node bindings to libvlc. Check out the wcjs-player & wcjs-prebuilt modules if you want to go this way, they are node wrappers for the webchimera.js video player, which uses VLC in the background. (I'm not affiliated with them, just currently using the modules for something similar in one of my projects with success so far.)
I'm sure there are other solutions to this, but these are the most logical ones I've found while researching on the subject. Hope this helps!

If you're like me and you encountered this thread after searching for something like ".mkv Electron" just be aware that the current top response is no longer accurate.
Electron now plays .mkv files natively with <video> elements along with a number of other formats likely including .Avi. Don't be like me and try to go down the horrible rabbit hole that is webchimera and trying to get it to work with electron.

Related

Is Node.JS audio mixing + MP3 generation possible?

In short, I have a site where on the client side the user has a "beat maker" app. The user can turn on / turn off noises, background beats, etc, to essentially create their own custom "song" based on the pre-defined noises, tones and tunes that I have on the client side.
I need to somehow translate the beat they're making (in HTML5 canvas) to my server-side (currently Node.JS) and spit out an MP3 of their creation.
Basically I have to somehow have my server-side backend gracefully concatenate + overlap + mix various smaller MP3/wav files into one MP3 file that matches the beat that they created on the client side. I then have to return that MP3 to the client side for download.
Anyone able to point me in the right direction?
As far as my research indicates, this isn't easily accomplished or feasible at all (I.E. within realistic budget / time constraints of the project) due to the complexity of the problem at hand.
This is possible, and there are some audio libraries for JavaScript, but I would take a different approach.
The Web Audio API is very solid these days. You can have your user make all the adjustments client-side, and then generate the audio file right there in the user's browser. If you need to get a copy server-side, you can upload the raw PCM to your server (bandwidth intensive), or send the parameters to the server and re-generate the file.
Now unfortunately, PhantomJS doesn't support Web Audio. To generate a perfect server-side copy, I would execute Chrome with a special page that renders the audio and then uploads to the local server. This guarantees that the sound output you get is the exact same as that of the client, and leaves all of the heavy lifting to the Web Audio API already implemented in the browser.
You won't find much off-the-shelf for a project like this, but with a little creativity I think you will find that this isn't too difficult.

Compressing audio files similar to transfer from server to client

In my project, I need to be able to compress small audio files so that it can be transferred easily from server to the client. I found We Chat uses audio compression closest to my requirement. But I couldn't find ways of doing it
I'm able to write code for image compression by reducing resolution and clarity. What should I try here ? combine two frames into one etc. Streaming is definitely possible if two frames are mixed into one. I want to know if there are any well developed libraries to do the same. I'm easy on the format until client side is able to read it. I also want to know if streaming is possible in compressed format.
I run a wiki that deals with the specifics of all kinds of multimedia technology. You might be interested in the Audio Codecs category, currently cataloging about 150 different audio codecs.
I can't tell from your question if you control both the client and server, or if you only control the server. If you control both, try a simple IMA ADPCM variant in order to get started. If you don't control the client, then of course your will need to code towards whatever the client can support.
There are many more codecs, of course, and lots of them have existing open source implementations that you may wish to leverage.

how to stream my video collection into inet

I have a small ubuntu server down in the basement with a couple of self made movies on it. I would like to share those videos with my Family. In my most fancy dreams, I would offer a website with the list of videos to select one and watch it. Let's say, something like youtube but with my very private stuff and only accesible for me and my family.
I am a more or less experienced linux user. I was allready googling a bit. I found Flumotion Streaming server but wanted to get my mind up for alternatives before instaling it. I would appreciate any hints for any other tools. Configuration via command line or plain config file would be ideal.
thanks
PS: I have a 5 MBit/s Upstream to internet. This should hopefully be enough for one client at a time.
Nowadays, most web-browsers support the html5 <video> tag. So, you don't even need to install flash/silverlight or other 3rd party tools. All you need to create your video portal/site is:
a) A web server software (Apache has good functionality, but lighttpd is quite light on resources. Both are available in Ubuntu repository.
b) Your videos. Chrome currently supports mp4, webm & ogg formats, so your video should be in one of these (See here for full details: http://www.w3schools.com/html/html5_video.asp)
Once you setup the above, all you need to do is create a default html page with description of videos along with a <video> tag to stream videos. See above w3schools link to know sytax and other trivia.

Streaming Audio with Java

I am building an application which collects speech via microphone as wav files. These recordings need to be streamed to a server and saved (as wav files, I know they are big but they have to be wav). I also need to stream audio (these can be mp3) from the server to the web application to be played for the user. I have no idea how to implement this, but I would like to use a Java EE application because I am familiar with Java and it's easier to maintain than Flex (we are having trouble with old Flex code at work). My concerns are:
How do I buffer the transmission so that users hear the whole file without breaks? Transferring the whole file and then playing it is fine, too, but knowing how to do this would be nice.
How do I verify transmissions to the server? Can I send in packets and verify/resend per packet?
Are there existing APIs for this (please!) or do I have to write this all by hand?
As I commented on your question, it is unclear whether you have already decided upon which components exist in the topology. In particular, it is unclear whether you already have a server process in charge of storing those audio files. Therefore, I will have to make a few assumptions in my answer. Feel free to comment, and I'll try my best to adjust.
The only way to ensure that an audio file is played (by the end user) without network-induced breaks is to have the end-user (or an application running at the end-user's side, such as some JavaScript code) play the audio stream after it was downloaded in its entirety. Unless you do that, you can only reduce the risk of breaks; you cannot eliminate it. Even the most sophisticated buffering algorithm cannot cope with a network outage 99.99% into buffering the entire stream. As I am not sure whether you have a client-side application involved in this, I can't advise how to force the client-side to download the entire file rather than playing it "as it comes"; in the simplest case, you might be able to suffice with using the Content-Disposition header: http://en.wikipedia.org/wiki/MIME#Content-Disposition
The answer to this question, again, depends on how you architect the solution. In general, though, as long as you use standard stream API's (such as Java IO), I wouldn't worry too much about verifying the content for errors. Error-correction is already provided lower in the networking stack (for example, your operating system's networking driver).
Apache Commons' File-Upload might be useful - again, depending on your architecture: http://commons.apache.org/fileupload/

how to implement a web site like youtube?

I'm doing a language web site for my university language center, where students login and see videos to learn English. i have to do it like this,
person is logging in to the system, search using a search area and find the details,lessons and videos relevant to that videos. this functionality exactly matches the youtube scenario.
for implementing twitter like functionality we can use status-net, is there a similer library, statusnet like famous implementation for youtube or a some kind of platform or a framework like codeigniter that we can use to implement youtube like site very easily??
please suggest some options?? a open source one or a commercial one ???
and what is the best video format to use in a such web site?? flv?? mp4?? or mov???
regards,
Rangana
Your best option is to use a 'cloud' based video processing service. Most have a sample project / library for many different languages and frameworks. Here is a list of a few I've tried and liked:
http://zencoder.com/
http://transloadit.com/
http://pandastream.com/
The typical steps involve uploading the video files to a large 'cloud' static asset host (such as S3) through the browser. If you are inexperienced it is best to select a processor that provides an uploader (it will handle putting the files in the right spot). Of the three, Transloadit and Panda both have custom unloaders.
Usually the service will allow you to either pass the encoding settings (what formats and qualities to) output to as parameters or configure them in your account. To support all current HTML5 browsers you just need H264 (.m4a) and OGG (.ogv). However, the new trend in the video world is for WEBM (.webm) so you might want to include it as well.
Next you will receive a unique code from the web service that you must store in persistent storage (database). The web service can be configured to 'callback' (perform an HTTP POST or GET request to your service) once the video is encoded.
Once your recieve a callback you can activate your video and start dislpaying it on your pages. For displaying, if you are inexperienced I'd highly recommend you use one of the following players:
http://sublimevideo.net/
http://longtailvideo.com/
http://videojs.com/
They all do similar things for different prices. My current personal favourite is Sublime Video (it offers cool light box effects and a gorgeous player).
Why do you have to re-implement Youtube when you can just use it for hosting your videos for free? Many online e-learning portals (e.g. Khan academy) do exactly that.
As far as the best video format to use -- go read about H.264/AVC. It's what Youtube currently uses.
I think you will not find already built solution ;)
But it's not really that hard. You can use existing frameworks that will make your life easier while you build account management system, the rest shouldn't be really that hard (assuming you don't really want to re-build the whole Youtube ;D ).
For playing videos, you can use JW Player. A great piece of software, you should check it out.

Resources