Code Monkey home page Code Monkey logo

edi-cam's Introduction

edi-cam

edi-cam demonstrates live video streaming on Intel Edison using Node.js and WebSockets. Audio is not supported at the moment. See the demo in action here.

The Node.js server is responsible for:

  • Listening for the incoming video stream via HTTP. ffmpeg, a multimedia framework for converting and streaming audio / video, is used to encode the webcam's video to MPEG1.
  • Broadcasting the video stream via WebSockets to all connected browsers.
  • Serving web/client/index.html, which renders the video stream onto a canvas element. jsmpeg, a JavaScript MPEG1 decoder, is used to decode the video stream.

This project was inspired by phoboslab.

Setup

To get started with Edison if you have never set it up before, see this post. The most relevant sections are "Connecting Edison" and "Connect Edison to WiFi". Although the instructions are for the Arduino breakout board, setup is similar for the Mini breakout board: Snap Edison onto the left side of the board, then connect two micro USB cables to the board and to your computer.

The setup assumes that Edison and your computer are on the same Wi-Fi network. This is also the case for additional computers that are used to view the video stream.

With Edison and your computer on the same Wi-Fi network, it is also possible to connect to Edison wirelessly via SSH. This is particularly helpful when running the demo. To do so, open a new terminal window and type the following:

$ ssh [email protected]
[email protected]'s password:
root@myedison:~#

Replace myedison with the name of your Edison. When prompted for your password, use the password you created when configuring Edison.

Setting up hardware

Use a UVC-compatible webcam. In my setup, I am using the Creative Live! Cam Sync HD 720P.

External power (7-15 VDC) must be supplied to use Edison as a USB host. Refer to the appropriate item below (based on the board you have) to power and connect a USB device:

  • If you have the Arduino breakout board, see this document. Power must be supplied on J1 (the power jack). Plug the webcam into the USB port next to the power jack. Make sure the switch SW1 is switched towards the USB port.
  • If you have the Mini breakout board, see this document. Power must be supplied on J21 / J22, e.g. a 9V battery can be connected to J21 with a 2-pin connector. Connect a micro USB to USB OTG adapter to the webcam and plug into the micro USB port closest to J21 (lower right).

Installing packages

Configuring the package manager

Edison's operating system is based off Yocto Linux, which uses opkg as its package manager. AlexT's unofficial opkg repository is highly recommended for adding packages to Edison. It includes many useful packages, such as git and the UVC driver.

To configure the repository, add the following lines to /etc/opkg/base-feeds.conf:

src/gz all http://repo.opkg.net/edison/repo/all
src/gz edison http://repo.opkg.net/edison/repo/edison
src/gz core2-32 http://repo.opkg.net/edison/repo/core2-32

The configuration used in this demo is also provided for reference. If /etc/opkg/base-feeds.conf is empty, simply copy this file into /etc/opkg/.

Update opkg:

opkg update

If the update is successful, the output should look like this:

Downloading http://repo.opkg.net/edison/repo/all/Packages.gz.
Inflating http://repo.opkg.net/edison/repo/all/Packages.gz.
Updated list of available packages in /var/lib/opkg/all.
Downloading http://repo.opkg.net/edison/repo/edison/Packages.gz.
Inflating http://repo.opkg.net/edison/repo/edison/Packages.gz.
Updated list of available packages in /var/lib/opkg/edison.
Downloading http://repo.opkg.net/edison/repo/core2-32/Packages.gz.
Inflating http://repo.opkg.net/edison/repo/core2-32/Packages.gz.
Updated list of available packages in /var/lib/opkg/core2-32.

Cloning this repository onto Edison

To install git:

opkg install git

Then clone this repository using git clone <git repo URL>.

Installing the UVC driver

Older versions of the Edison Yocto image do not contain the UVC driver. To check whether or not the UVC driver is installed, type the following:

find /lib/modules/* -name 'uvc'

If the UVC driver is installed, the output should look something like this:

/lib/modules/3.10.17-poky-edison+/kernel/drivers/media/usb/uvc

If nothing is returned, the UVC driver needs to be installed:

opkg install kernel-module-uvcvideo

To make sure the UVC driver is loaded and the webcam is detected properly, plug in your webcam, then type lsmod | grep uvc:

root@myedison:~# lsmod | grep uvc
uvcvideo               71516  0
videobuf2_vmalloc      13003  1 uvcvideo
videobuf2_core         37707  1 uvcvideo

Also, verify that the video device node has been created by typing ls -l /dev/video0:

root@myedison:~# ls -l /dev/video0
crw-rw----    1 root     video      81,   0 Nov 10 15:57 /dev/video0

Installing ffmpeg

To install ffmpeg:

  • Navigate to bin.
  • Type ./install_ffmpeg.sh to run the shell script.

If the download doesn't work, the release link may have changed. Check here, copy the address of the latest release, and replace in the shell script.

Installing Node.js packages

  • Navigate to web/server.
  • Install the Node.js packages by typing npm install.

Running the demo

Running the Node.js server

  • Navigate to web/server.
  • Run the server by typing node server.js.

The Node.js server should now be running. The console will look something like this:

WebSocket server listening on port 8084
HTTP server listening on port 8080
Listening for video stream on port 8082
Stream Connected: 127.0.0.1:52995 size: 320x240

Viewing the video stream

Open a browser window and navigate to http://myedison.local:8080, where myedison is the name of your Edison. You should now see the video stream from your webcam!

edi-cam's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

edi-cam's Issues

Can't change the Resolution of camera output.

After completing current guide, I successfully got 320*240 live video streaming through Intel Edison.
BUT
1./edi-cam/web/server/server.js
2./edi-cam/web/client/index.html
3./edi-cam/bin/do_ffmpeg.sh
But unfortunately instead of 360p live streaming we got leggy low resolution video.
I use Logitech 720p Camera.
Please help me for Getting 720p live video streaming.
email: [email protected]

edi-cam on galileo

Hi,
I have been trying to use your code with the Galileo board. Is there something I should be aware of within the code that's specific to Edison?? I changed to the appropriate repository for opkg and made sure my webcam is compatible with uvc.
When I run server.js everything seems fine, but when I connect to the http server through my pc browser the loading notice shows shortly, and then nothing just a white image. There's no error with the web sockets nor the firewall. Also the led indicator in my webcam only stays on for 1 second or less then it shuts down.
Thanks for your help

Stream freezes after 2 minutes

Hey,

two minutes after starting the stream the stream freezes due to a timeout. This can be fixed by adding

req.connection.setTimeout(0);

around line 70 of server.js

I'm surprised this has not been noticed yet, has this not happened to anyone else?

Greets

Problem with npm install

Now that I am able to run my server succesfully, do you know the commands to check if my npm is properly installed?

I tried a "npm install" command again instead of the output being up-to-date, it shows me

npm ERR! install Couldn't read dependencies
npm ERR! package.json ENOENT, open '/home/root/package.json'
npm ERR! package.json This is most likely not a problem with npm itself.
npm ERR! package.json npm can't find a package.json file in your current directory.

npm ERR! System Linux 3.10.17-poky-edison+
npm ERR! command "node" "/usr/bin/npm" "install"
npm ERR! cwd /home/root
npm ERR! node -v v0.10.38
npm ERR! npm -v 1.4.28
npm ERR! path /home/root/package.json
npm ERR! code ENOPACKAGEJSON
npm ERR! errno 34
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     /home/root/npm-debug.log
npm ERR! not ok code 0

editing ffserver.conf file

hello,

I wanted to edit ffserver.conf file and make some changes in there related to video size.
I want my camera to stream video of 960x720 resolution. right now it is streaming only 320x240 resolution as it may be specified in the ffserver.conf file.
I can edit the size of container in index.html page, but it just stretches size of window and not taking higher input size.
How can i do that ? I found the ffserver file (of size 26 MB) in /home/root/bin/ffmpeg directory, but it is in compiled format. So i cannot edit it. Can you suggest me any solution ?

camera crashes at resolution of 640*480

hello,

I tried to run the project with required modifications in
bin/do_ffmpeg.sh , client/index.html , & server/server.js files.
I replaced 320_240 with 640_480 (also tried other combinations)
But now when I run the node server.js , the camera blinks once and then it turns off.
So i cannot get video stream of my desired size.
(I'm using Logitech C270 camera with 1280*720 HD input capacity)
how should I solve this ?

thank you.

streaming

hello,
first of all i want to thank you for this tutorial. i also want to ask you if you can explain how to from the cloning part an on. i been trying to stream but i can not get pass the installing the ffmpeg.

npm packages

Hello drejkim,

I was not having much knowledge in using the npm/java.
As i was following the instructions on readme file, while doing npm install, i was getting few errors and i was not successful in installing the dependencies.
log(npm install):
root@edison:~/edi-cam/web/server# npm install
npm WARN package.json [email protected] http is also the name of a node core module.
npm WARN package.json [email protected] No description
npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] No repository field.
npm http GET https://registry.npmjs.org/ws
npm http GET https://registry.npmjs.org/express
npm http 304 https://registry.npmjs.org/ws
npm http 304 https://registry.npmjs.org/express
npm ERR! Failed to parse json
npm ERR! Unexpected end of input
npm ERR! File: /home/root/.npm/express/4.10.1/package/package.json
npm ERR! Failed to parse package.json data.
npm ERR! package.json must be actual JSON, not just JavaScript.
npm ERR!
npm ERR! This is not a bug in npm.
npm ERR! Tell the package author to fix their package.json file. JSON.parse

npm ERR! System Linux 3.10.17-poky-edison+
npm ERR! command "node" "/usr/bin/npm" "install"
npm ERR! cwd /home/root/edi-cam/web/server
npm ERR! node -v v0.10.28
npm ERR! npm -v 1.4.9
npm ERR! file /home/root/.npm/express/4.10.1/package/package.json
npm ERR! code EJSONPARSE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/root/edi-cam/web/server/npm-debug.log
npm ERR! not ok code 0

log(node server.js):
root@edison:~/edi-cam/web/server# node server.js

module.js:117
throw e;
^
SyntaxError: Error parsing /home/root/edi-cam/web/server/node_modules/express/package.json: Unexpected end of input
at Object.parse (native)
at readPackage (module.js:113:52)
at tryPackage (module.js:123:13)
at Function.Module._findPath (module.js:190:18)
at Function.Module._resolveFilename (module.js:336:25)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object. (/home/root/edi-cam/web/server/server.js:3:15)
at Module._compile (module.js:456:26)

Is there any thing I'm missing ? can you please help me with this problem.

Bhuvan

i want to send a message from client to server ? how can i ?

i want to send a message from index.html to server in edi-cam project

i make a button in index.html
if user push a button and then some message is sended to server
and as message server do something

so i think,

  1. fix index.html
  2. fix server.js , fix routs.js

? how can user send client's custom message to server?

is this right?

ERROR: The certificate of 'www.johnvansickle.com' is not trusted.

when i tried to run ./install_ffmpeg.sh

Creating ~/bin directory if it doesn't exist...
Removing old versions of ffmpeg...
Downloading ffmpeg...
--2015-06-19 06:03:21-- http://johnvansickle.com/ffmpeg/releases/ffmpeg-release-32bit-static.tar.xz
Resolving johnvansickle.com... 162.222.226.121
Connecting to johnvansickle.com|162.222.226.121|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://www.johnvansickle.com/ffmpeg/releases/ffmpeg-release-32bit-static.tar.xz [following]
--2015-06-19 06:03:37-- https://www.johnvansickle.com/ffmpeg/releases/ffmpeg-release-32bit-static.tar.xz
Resolving www.johnvansickle.com... 162.222.226.121
Connecting to www.johnvansickle.com|162.222.226.121|:443... connected.
ERROR: The certificate of 'www.johnvansickle.com' is not trusted.
ERROR: The certificate of 'www.johnvansickle.com' is not yet activated.
The certificate has not yet been activated
Unpacking...
tar: can't open '/home/root/bin/ffmpeg-release-32bit-static.tar.xz': No such file or directory
Cleaning up...
rm: can't remove '/home/root/bin/ffmpeg-release-32bit-static.tar.xz': No such file or directory
mv: can't rename '/home/root/bin/ffmpeg*/': No such file or directory

I didnt change code, and gone through the similar issues but I didn't find how to resolve it.

Motion detecting function

Hello,
I have been trying to modify a motion detecing function on your project.

I have found a similar link regarding this function however I am unable to do so.

Do you have any guide i am able to follow regarding motion?

Cheers!

Installing the UVC driver problem with 05-15 Yocto Image

Yesterday I loaded the latest Yocto image from Intel and proceeded to follow the edi-cam instructions. In doing so I noticed performing opkg install kernel-module-uvcvideo will break the now included uvcvideo. This step is no longer needed with the latest Yocto build.

Streaming on Mobile

First of all, thanks a lot for this project. I followed the instruction and was able to stream video on browser. This works within same network. How can I make my edison streaming accessible from outside my home network? I want to make a mobile app and stream on the app. Any idea?

Video Streaming using C++ in OpenCV

Hi @drejkim

Thanks for sharing this project.

Can I write C++ code in openCV to view the video streaming instead of using web browser?

The C++ coding that i wrote as follow:

include <opencv/cv.h>

include <opencv2/highgui/highgui.hpp>

include <opencv2/imgproc/imgproc.hpp>

include

include <stdio.h>

using namespace std;
using namespace cv;
int main()
{
Mat frame;
namedWindow("video", 1);
VideoCapture cap("http://192.168.8.102:8080/video.mjpg");
if(!cap.isOpened())
{
cout<<"Camera not found"<<endl;
getchar();
return -1;
}
while ( cap.isOpened() )
{
cap >> frame;
if(frame.empty()) break;
imshow("video", frame);
if(waitKey(30) >= 0) break;
}
return 0;
}

When running the C++, it does not show me the video and show me "Camera not found".

However, in Intel Edison terminal, it shows:
"GET /video.mjpg 206 87.816 ms - 1248"
screenshot from 2016-10-01 18-26-32

Can you give me some advice and idea? Thank you.

Code

I'm reviewing the code. And these lines still do not understand them. Could you help me please

In server.js

// serve index
require('./lib/routes').serveIndex(app, configServer.staticFolder);

According to understand, after this line is to run in the index.js
But I do not understand that now makes the file index.js

In index.js

// Load the single view; AngularJS will handle view changes on the front-end
// NB: This needs to be the last route added

exports.serveIndex = function (app, staticFolder) {
app.get('*', function (req, res) {
res.sendFile('index.html', { root: staticFolder });
});
};

USB camera freeze

Hi. I followed every step as you have described on my intel edison to get a video stream on my browser.
I have used A4 tech USB web cam. the problem is the video displayed in of a still image. it doesn't show live stream.
can u kindly help me in this ?

Edi-cam with Public ip

Hi, i was looking to make a surveillance camera with a public ip but is not working at all. Can you help me with that?

server not implemented

My webcam is Logitech C270 however when i node server.js it only display

WebSocket server listening on port 8084
HTTP server listening on port 8080
Listening for video stream on port 8082

According to your documentation, there is a missing line of
"Stream Connected: 127.0.0.1:52995 size: 320x240"

Also, when i run my web server of http://172.27.152.201:8084 , only a white screen with words "not implemented" is displayed.

Can you suggest where did i go wrong?

Cheers!

Screenshots

Hi, i'm trying to implement screenshots on motion detection using ffmpeg.
I tried several solutions but i'm running into a stumbling block with the right video source. i can't use '/dev/video0' because 'resource is in use (by edi-cam)' and a direct http output isn't working (using http://127.0.0.1:8082). Any ideas ?

Also as this isn't really an "issue" i tried to avoid starting one up, but couldn't find a reliable way to contact you. Thanks

Setting up ON and OFF button

Hi,

May i know if it is possible to create a ON and OFF button on the webpage?
If it is, any guide that i can follow through?

Cheers!

About the 1080p , Video quality and Bitrate .

Dear Drejkim

Could you help "how to setup the Video quality and Bitrate up to 4Mbit/s" ?

I change the file "do_ffmpeg.sh" and "jsmpg.js" is not working .

By a way , the 1080p can't working in 2Mbit/s.

The usb will display error -71

My camera is logitech c910 .

how to increase display size of the video ?

hello, I've successfully got the streaming output of this project on Intel Edison mini breakout board.
I'm using Logitech c270 HD camera, which has input capacity of 720p.

But I got only 320*240 resolution image in browser on http://myedison.local:8080/
what changes should I make to get the 720p output.

thanks.

Adding facial recognition

Hi,

I want to add facial recognition to your project, can you guide me to where within the code can I take the frame coming from the stream do the recognition and then display it in the http server?

Thanks

Connect cam to ZoneMinder

Hi @drejkim,

Thank you for building this project. I have the cam working and can load the video feed in a web browser just fine. Setting up a monitor in ZoneMinder for the camera feed fails though. Have you tried pointing ZoneMinder or any media player that speaks RTP/RSTP at the Edison host to see if that works?

Thanks a bunch!
Ulf

adding edi-cam into my yocto image

Hi,
I'm a total newbie and I want to include edi-cam functionality into custom yocto image.
I want to stream video from my Intel Edison mini breakout board, for that currently I have to clone
edi-cam and then use it.
But now I want to add it into my image.
can you please help me ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.