I'm using vid-streamer https://github.com/meloncholy/vid-streamer.
- To install just create a folder on your pc
- open terminal and do CD to folder
- execute npm init
- give the app a name like 'MyVidStreamer'
- a package.json will be created
- npm install express
- create a server.js on the same folder of package.json
write this and save
var app = require("express");
var app = app();
var vidStreamer = require("vid-streamer");
app.get("/videos/:type", vidStreamer); //{folder}/{videoName.extension}
app.listen(3000);
update the vid-streamer configuration: open node_modules/vid-streamer/config/ and edit the json file vidStreamer-sample.json:
{
"mode": "development",
"forceDownload": false,
"random": false,
"rootFolder": "", <----
"rootPath": "", <-------
"server": "VidStreamer.js/0.1.4",
"maxAge": "3600",
"throttle": false
}
- create a folder named videos at the same level of our server.js
- add a avi file inside of it
- on the terminal make cd followed by path to the folder where we have our server.js
- run node server.js
- open browse and type 'localhost:3000/videos/{name_of_your_vid_File.extension}
I'm able to stream mp4 files and ogg, but not avi files.
so the question is how can i fix this in order to stream avi files
First of all, you should know that browsers are not video players so you can not expect that a browser can play any format of videos !
In addition, not all video formats are suitable for the web for many reasons, so try always to take this point on consideration when you want stream videos, and think how to make your video suitable for the web and not how to make web suitable to your video ( like your question ;) ).
Recent browsers can support natively some video formats like MP4, WEBM and OGG which will be played using the HTML5 <video>
element, in the case where a video format is not natively supported, the browser will try to play it with a plugin like VLC Web Plugin, QuickTime, Osmozilla - GPAC Plugin, ... otherwise ( there are no suitable plugin ), the browser will simply download the file (or open it with the associated application after asking user).
So to "resolve your problem", I think that you have 2 choices :
- Convert your videos to natively supported formats.
- Force users to get the suitable plugins for your videos, which is technically impossible.
For more informations about all that and more, you can take a look on these links :
- Mozilla Developer Network : Media formats supported by the HTML audio and video elements.
- The Chromium Projects : Everything you need to know about audio/video inside Chromium.
- Wikipedia : HTML5 video.
- caniuse.com : MPEG-4/H.264 video format ( see also the Resources tab at the bottom ).
- caniuse.com : WebM video format ( see also the Resources tab at the bottom ).
- caniuse.com : Ogg/Theora video format ( see also the Resources tab at the bottom ).
- Microsoft Developer Network : How to use HTML5 to play video files on your webpage.
- Dev.Opera : Introduction to HTML5 Video.
Of course here I tried just to give you a short "answer" to your question about playing video directly in the browser ( without HTML ), and I think after this, you will surely think to play your videos in HTML pages, you can also find an answer for that in the links above.
Hope all that can help.