Giter Club home page Giter Club logo

mjpgserver's Introduction

Dual stream motion JPEG server

This repository contains an HTTP server that's streaming both a low resolution MJPG stream from your webcam, and allow simultaneously (or as close as simultaneously that's possible) capturing a full resolution JPEG picture from the camera.

This is very useful for monitoring a 3D printer (via Octoprint for example) without consuming too much bandwidth and still be able to capture high resolution pictures to make a timelapse of the 3D part being built (via Octolapse).

The server is very lightweight. It does not use CPU for image processing or rescaling and instead only rely on the webcam supporting MJPG encoding by itself. It should be suitable for embedded and low power system like a Raspberry Pi board.

How does it compare to competitors ?

While there are numerous software that are able to stream a MJPG stream from a webcam, as far as I know, none of them allow simultaneously capture a stream in multiple resolution. Either the software will capture the stream in high resolution and then, decode, rescale and re-encode a low resolution stream, like this, or it's not possible at all.

The most common software is mjpg-streamer. With this software, the only way to support dual stream is to have 2 camera and running 2 instances of the server (one serving the first camera, while the other serving the second camera)

This repository allows to use a single camera for this purpose.

Requirements

The software here is made for linux. It might work on other POSIX system with a V4L2 subsystem, but it's not tested. It won't work for Windows either since it's using Video4Linux 2 API to fetch the stream of the camera.

It requires a camera that's supporting MJPG format (most recent webcam do). It won't work for camera not supporting such format, since there is no JPEG encoder in the software.

It'll obviously work better if the camera supports multiple resolutions (in that case, the highest supported resolution is used for the picture and a VGA resolution stream is used for the low resolution stream).

Technical internal working

The software runs a V4L2 thread that's fetching the low resolution stream as long as there are connected clients.

When the full resolution URL is requested, the low resolution stream is stopped, the camera resolution is changed to the high resolution and the streaming is started for getting one single frame that's answered to the request, then the low resolution stream is restarted. In effect, it appears like a small pause in the live stream (less than 3 or 4 frames on my computer) so it shouldn't be too painful.

License

This code is dual licensed under GPLv3 license and a commercial license.

The basic idea here is that the code should be free as long as you don't earn money from it (it's ok to use this code to make wonderful timelapses, but not to build a commercial service with it).

If you need to use this software commercially, feel free to send me an email, I'll answer promptly.

Example usage

If you need some documentation to use it, feel free to read this blog item

Documentation for building and testing it is here

mjpgserver's People

Contributors

x-ryl669 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

salvadorant

mjpgserver's Issues

An error occurred while compiling for arm Linux

Hi!I tried to build this project for my Raspberry 4B (arm v7),but occurred a error:

Computing dependencies for V4L2Source.cpp
Computing dependencies for MJPGServer.cpp
Compiling MJPGServer.cpp
Compiling V4L2Source.cpp
Compiling Threads.cpp into ClassPath/Threading/
Compiling Lock.cpp into ClassPath/Threading/
/tmp/ccNHhirf.s: Assembler messages:
/tmp/ccNHhirf.s:3382: Error: selected processor does not support `yield' in ARM mode
/tmp/ccNHhirf.s:3409: Error: selected processor does not support `yield' in ARM mode
make: *** [Makefile:78: ClassPath/Threading/Lock.o] Error 1

make --version :GNU Make 4.2.1
gcc -v :gcc version 8.3.0 (Raspbian 8.3.0-6+rpi1)

Thanks!

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.