Giter VIP home page Giter VIP logo

livecam's Introduction

livecam

Webcam live-streaming solution using GStreamer and Node.js

Installation

To obtain this module, type in npm install livecam. You also need GStreamer 1.3+ runtime installed on your machine.

Windows

Depending on your architecture, you may download the latest runtimes provided and maintained by the GStreamer project. They usually come in MSI installer format. You do not need the development installers. Naming of the runtime package follows the gstreamer-1.0-<arch>-<version>.msi convention.

Make sure you select COMPLETE installation and NOT typical. If you go with typical, ksvideosrc plugin will not be available for you, and livecam will not be able to use it.

After installation, make sure you have GSTREAMER_1_0_ROOT_<arch> environment variable defined in your system. This is a variable created by the MSI installer, pointing to where you installed the runtime package. You might need to restart your computer after installation for this variable to show up.

Linux

GStreamer might be already available on your machine. You may verify its existence by typing gst-launch-1.0 --version on your command line. If this command is not available, you can obtain GStreamer from your distro's package manager. For example on Ubuntu 16.04:

$ sudo apt install libgstreamer1.0-dev
$ sudo apt install libgstreamer-plugins-*1.0-dev

Mac OSX

You may obtain GStreamer runtime via Homebrew.

$ brew install gstreamer         # install gstreamer
$ brew install gst-plugins-good  # general plugins
$ brew install gst-plugins-bad   # mac video sources etc.

Usage

// npm install livecam

const LiveCam = require('livecam');
const webcam_server = new LiveCam({
    'start' : function() {
        console.log('WebCam server started!');
    }
});

webcam_server.broadcast();

If all goes fine, you will see a message like this in your console: Open http://127.0.0.1:11000/ in your browser!.

Configuration

LiveCam takes an object in as its launch configuration:

// npm install livecam

const LiveCam = require('livecam');
const webcam_server = new LiveCam
({
    // address and port of the webcam UI
    'ui_addr' : '127.0.0.1',
    'ui_port' : 11000,

    // address and port of the webcam Socket.IO server
    // this server broadcasts GStreamer's video frames
    // for consumption in browser side.
    'broadcast_addr' : '127.0.0.1',
    'broadcast_port' : 12000,

    // address and port of GStreamer's tcp sink
    'gst_tcp_addr' : '127.0.0.1',
    'gst_tcp_port' : 10000,

    // callback function called when server starts
    'start' : function() {
        console.log('WebCam server started!');
    },

    // webcam object holds configuration of webcam frames
    'webcam' : {

        // should frames be converted to grayscale (default : false)
        'grayscale' : true,

        // should width of the frame be resized (default : 0)
        // provide 0 to match webcam input
        'width' : 800,

        // should height of the frame be resized (default : 0)
        // provide 0 to match webcam input
        'height' : 600,

        // should a fake source be used instead of an actual webcam
        // suitable for debugging and development (default : false)
        'fake' : false,

        // framerate of the feed (default : 0)
        // provide 0 to match webcam input
        'framerate' : 25,

        // macos only: select the webcam via index
        'deviceIndex' : 1
    }
});

In the configuration above:

NOTE 1 broadcast address and UI address need to be visible to each other. NOTE 2 broadcast address and gst_tcp address need to be visible to each other. NOTE 3 UI address and gst_tcp address need NOT to be visible to each other.

That means you can hide gst_tcp address behind your firewall.

FAQ

  • Q. What's the max resolution supported for broadcast? A. This is a very generic and broad question, and the answer to it is highly platform, network, and hardware dependent. If you are looking for a generic answer, I have successfully streamed 1920x1080@30fps in my home network to five different clients (including a Galaxy Edge) at once.

  • Q. Can this module stream a static file instead of a webcam? A. Yes. in livecam.js, look for gst_video_src variable and assign the following value to it:

    // assuming you're on Windows and the file is on C:\videos\stream.mp4
    // NOTE the four backslashes!
    var gst_video_src = 'filesrc location="C:\\\\videos\\\\stream.mp4"'

License

LGPL-v3.0.

livecam'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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

livecam's Issues

Video d'ont display

The attribut src to the image is always empty
they no error in console but the socket don't work

Server not starting

Hi !

I just discovered this package that looks perfectly fitting my need ! However, I don't manage to make the server start.

I'm on Ubuntu, with an USB webcam, I put the example code in scripts/startCameraServer.js.

When I run node scripts/startCameraServer.js, the red LED of my webcam turns on and I have the following logs:

LiveCam parameters: { broadcast_addr: '127.0.0.1',
  broadcast_port: 12000,
  ui_addr: '127.0.0.1',
  ui_port: 11000,
  gst_tcp_addr: '127.0.0.1',
  gst_tcp_port: 10000 }
GstLaunch found: /usr/bin/gst-launch-1.0
GStreamer version: 1.8.3
GStreamer pipeline: v4l2src ! decodebin ! videoscale ! video/x-raw,width=800,height=600 ! videobalance saturation=0.0 ! videoconvert ! jpegenc ! multipartmux  boundary="--videoboundary"! tcpserversink host=127.0.0.1 port=10000
Définition du pipeline à PAUSED...

Le pipeline est actif et n’a pas besoin de phase PREROLL…

Passage du pipeline à la phase PLAYING…

New clock: GstSystemClock

I don't see WebCam server started! and I can't open http://127.0.0.1:11000.

I don't understand what is failling :-/

Streaming over internet

I'm trying to use LIvecam to stream over the internet, I can see my video using router ip plus port while in network, but when I try to see the video using 4G or other network I can't see it. It has some problem to stream using TCP over internet?

Video not showing up in windows

First of all, there was some problem with getVersion method, and I couldn't get it right - so I hard coded the version in the code to - "1.11.1" (My current one!), and then everything goes fine - no errors and webcam is switched on!, but when i open the livecam UI, all I see is a blank screen.

Output:
screenshot

I've created a gist for my current file state, you might have a look.

Showing empty screen in windows

In windows 10 I have installed Gstreamer version(gstreamer-1.0-x86_64-1.14.0.1.msi) and tried to run this module. But it is getting it as empty. Terminal it is showing it as below

Setting pipeline to PLAYING ...
New clock: GstSystemClock

Open http://127.0.0.1:11000/ in your browser!
WebCam server started!

It is working fine with linux machine.
Can you please help me, what is the issue over here.

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.