'Play local .avi videos in Node.js / Electron app
Maddening gap in an app I'm developing is there appears to be little (or no) support for AVI in the HTML5 video implementation. So, I need a workaround that is cross-platform, and package-able with my electron app.
- Videos are hosted locally
- I'm not averse to encoding on the fly (ffmpeg avi -> mp4 and use HTML5 natively?)
- WebChimera appears dying due to VLC and Electron changes (devs can't keep up) (Is there another npm package that can do this?)
- A wrapper that calls a native VLC instance might work -- but how do I ensure that VLC is available on the system with my packaging?
- Should I just spawn a native app in a separate window (ie, Totem on Linux)? (seems clunky)
- Latest videoj-java plugin apparently has issue (https://github.com/Afterster/videojs-java/issues/2) and adding another layer (java) to the electron stack seems somehow unsavory.
- FFBinaries (https://github.com/vot/ffbinaries-node) seems promising... but oddly FFPlay is not available for Linux (though I suspect my linux consumers likely have a ffmpeg already installed).
NB: Files are decidedly AVI. I can't change this.
Any hints / pointers greatly appreciated!
UPDATE
On my system, using ffmpeg to convert:
ffmpeg -i infile.AVI -vcodec copy -acodec copy outfile.mp4
Takes no time at all (they are short videos):
real 0m0.138s
user 0m0.100s
sys 0m0.032s
So I'm leaning toward packaging ffmpeg with my program and converting before loading.
Solution 1:[1]
Take a look at this project:
According to the known supported formats:
it supports:
- mp4
- webm
- ogg
- mov (MPEG4 | H.264)
- avi (MPEG4 | H.264)
- mkv (MPEG4 | H.264)
- m4v (MPEG4 | H.264)
Take a look at its source code and see if you can implement it similarly.
You said that you need AVI support but AVI is just a container - if you need other codecs than the ones supported by this project then you will still need to transcode it first.
If you cannot do it like this then you may try using something similar to:
and bundle mplayer with your app, or some other player.
Solution 2:[2]
According to this SO answer, Electron now suports multiple video formats in the <video> tag, including .mkv, .avi and other formats. You don't need to rely on an external player.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | rsp |
| Solution 2 | Ambrus Tóth |
