WIFI webcam project based on mjpg-streamer

Elclaudio
2013-01-12
2013-05-30
  • Elclaudio

    Elclaudio - 2013-01-12

    Hi there

    I've in mind to build a wireless camera from scratch, based on a tiny arm computer board and a regular usb webcam. I've gathered enough information and I know this is possible with cheap hardware. I've buyed a logitech C270 webcam (UVC with MJPEG hardware support, very important here) but there is others cameras that work well to.

    I've tried mjpg_streamer on a cheap router at home (a netgear WNR3500L with toastman tomato custom firmware) and I've been amazed that a 400mhz arm device with 64Mb can stream 1280x720 @ 30 fps with very light cpu usage. So this convinced me to look for one of theses cheap arm board out there, and they are plenty of them, starting with the raspberry pi…

    But I've still not decided which one to pick yet, if any of you guys have such a device feel free to post here, I've read for example loads of power issues with the PI especially with usb devices connected (wifi + webcam is a lot of mA) and I don't want to add a usb powered hub.

    Also, I would like to know if there is plan to support audio streams with mjpg_streamer and rtsp as well

    Thanks and Bravo to the author

     
  • Elclaudio

    Elclaudio - 2013-01-27

    So, here's an update.

    I finally gone the hack way…by choosing a tiny router from TP-LINK the MR3020 with openwrt as the main OS. All I can say is this is working really well. I decided not to pick up a raspi because of numerous issues with the power supply and lack of build-in wifi and…price ! I've paid only 34€ for this, free shipping (but you can have it for way less on ebay)… the PI would have cost me 50€ without wifi, power supply, case !

    I've build a specific firmware with only the stuff I need and I plan to add a PIR Sensor via GPIO to trigger webcam snapshots. Wifi is very stable so far even with latest openwrt snapshot trunk and cpu usage with webcam streaming on is insignificant (MJPEG camera mandatory)

    I've only one issue with mjpg-streamer : controls doesn't work, they don't appear in the pop up window ONLY IF I run mjpg-streamer via the build in service in openwrt. If I launch it via the ssh console, the controls appears.
    Any suggestions?



     
  • Márton Miklós

    Márton Miklós - 2013-01-28

    What version of mjpg-streamer do you use?

     
  • Elclaudio

    Elclaudio - 2013-01-28

    hello martonmiklos

    I currently use r174 compiled from svn and I've also tried the experimental branch with same results. Also, I wonder if it's possible to apply pre-defined settings for the camera when launching mjpg-streamer ?

     
  • Márton Miklós

    Márton Miklós - 2013-02-06

    Sorry for the late response.

    Could you please check the serverip:port/input_0.json file contents.

    Also could you please check control page loading with firebug:

     
  • Elclaudio

    Elclaudio - 2013-02-06

    Hi ! thanks you for your response

    here the content of input_0.json

    {
    "controls": [
    {
    "name": "Brightness",
    "id": "9963776",
    "type": "1",
    "min": "0",
    "max": "255",
    "step": "1",
    "default": "128",
    "value": "128",
    "dest": "0",
    "flags": "0",
    "group": "1"
    },
    {
    "name": "Contrast",
    "id": "9963777",
    "type": "1",
    "min": "0",
    "max": "255",
    "step": "1",
    "default": "32",
    "value": "32",
    "dest": "0",
    "flags": "0",
    "group": "1"
    },
    {
    "name": "Saturation",
    "id": "9963778",
    "type": "1",
    "min": "0",
    "max": "255",
    "step": "1",
    "default": "32",
    "value": "32",
    "dest": "0",
    "flags": "0",
    "group": "1"
    },
    {
    "name": "White Balance Temperature, Auto",
    "id": "9963788",
    "type": "2",
    "min": "0",
    "max": "1",
    "step": "1",
    "default": "1",
    "value": "1",
    "dest": "0",
    "flags": "0",
    "group": "1"
    },
    {
    "name": "Gain",
    "id": "9963795",
    "type": "1",
    "min": "0",
    "max": "255",
    "step": "1",
    "default": "0",
    "value": "0",
    "dest": "0",
    "flags": "0",
    "group": "1"
    },
    {
    "name": "Power Line Frequency",
    "id": "9963800",
    "type": "3",
    "min": "0",
    "max": "2",
    "step": "1",
    "default": "2",
    "value": "2",
    "dest": "0",
    "flags": "0",
    "group": "1",
    "menu": {"0": "Disabled", "1": "50 Hz", "2": "60 Hz"}
    },
    {
    "name": "White Balance Temperature",
    "id": "9963802",
    "type": "1",
    "min": "0",
    "max": "10000",
    "step": "10",
    "default": "4000",
    "value": "4000",
    "dest": "0",
    "flags": "16",
    "group": "1"
    },
    {
    "name": "Sharpness",
    "id": "9963803",
    "type": "1",
    "min": "0",
    "max": "255",
    "step": "1",
    "default": "24",
    "value": "24",
    "dest": "0",
    "flags": "0",
    "group": "1"
    },
    {
    "name": "Backlight Compensation",
    "id": "9963804",
    "type": "1",
    "min": "0",
    "max": "1",
    "step": "1",
    "default": "1",
    "value": "1",
    "dest": "0",
    "flags": "0",
    "group": "1"
    },
    {
    "name": "Exposure, Auto",
    "id": "10094849",
    "type": "3",
    "min": "0",
    "max": "3",
    "step": "1",
    "default": "3",
    "value": "3",
    "dest": "0",
    "flags": "0",
    "group": "1",
    "menu": {"0": "Brightness", "1": "Manual Mode", "2": "rast", "3": "Aperture Priority Mode"}
    },
    {
    "name": "Exposure (Absolute)",
    "id": "10094850",
    "type": "1",
    "min": "1",
    "max": "10000",
    "step": "1",
    "default": "166",
    "value": "166",
    "dest": "0",
    "flags": "16",
    "group": "1"
    },
    {
    "name": "Exposure, Auto Priority",
    "id": "10094851",
    "type": "2",
    "min": "0",
    "max": "1",
    "step": "1",
    "default": "0",
    "value": "1",
    "dest": "0",
    "flags": "0",
    "group": "1"
    },
    {
    "name": "JPEG quality",
    "id": "1",
    "type": "1",
    "min": "0",
    "max": "100",
    "step": "1",
    "default": "50",
    "value": "0",
    "dest": "0",
    "flags": "0",
    "group": "3"
    }
    ],
    "formats": [
    {
    "id": "0",
    "name": "YUV 4:2:2 (YUYV)",
    "compressed": "false",
    "emulated": "false",
    "current": "false",
    "resolutions": {"0": "640x480", "1": "160x120", "2": "176x144", "3": "320x176", "4": "320x240", "5": "352x288", "6": "432x240", "7": "544x288", "8": "640x360", "9": "752x416", "10": "800x448", "11": "800x600", "12": "864x480", "13": "960x544", "14": "960x720", "15": "1024x576", "16": "1184x656", "17": "1280x720", "18": "1280x960"}
    },
    {
    "id": "1",
    "name": "MJPEG",
    "compressed": "true",
    "emulated": "false",
    "current": "true",
    "resolutions": {"0": "640x480", "1": "160x120", "2": "176x144", "3": "320x176", "4": "320x240", "5": "352x288", "6": "432x240", "7": "544x288", "8": "640x360", "9": "752x416", "10": "800x448", "11": "800x600", "12": "864x480", "13": "960x544", "14": "960x720", "15": "1024x576", "16": "1184x656", "17": "1280x720", "18": "1280x960"}
    ,
    "currentResolution": "18"
    }
    ]
    }
    

    And the firebug grab :

     
  • Elclaudio

    Elclaudio - 2013-02-06

    also, in this experimental branch, when I click the checkbox "show controls" in the stream page, nothing appear

     
  • Márton Miklós

    Márton Miklós - 2013-02-07

    Hmmm.
    The json is vaild, so something goes wrong on the client side.
    My first thougth was that I have missed to add something to the repo, but I have synced the last from the experimental and works fine with my Logitech C510.

    Is not there any errors in the firebug console after downloading the json files?

    And if my understanding is correct if you start it from command line it works, if you start it from an init script it does not.

    When the control page opens up (or at the stream you check the show controls), the client side downloads the progra.json the input_0.json and output_0.json files. (and more jsons if you use multiple plugins.)

    If some of these jsons are malformed the controls will not be able to load. We should check the following:
    A) What is the difference between these json files between sour starting methods.
    B) Is there any invalid json. Use http://jsonlint.com/ to check that.

    Thanks, and excuse me for the inconvinence.

     
  • Elclaudio

    Elclaudio - 2013-02-08

    Hi, don't need to apologise, you've made some great work here

    It seem's the program.json is not valid (only when it's run from openwrt service), I've pasted the text into an editor and there seem's to be 2 tab in there

    {
        "inputs": [
            {
                "id": "0",
                "name": "Camera 1",
                "plugin": "input_uvc.so",
                "args": "       --device /dev/video0 --fps 15 --resolution 640x480"
            }
        ],
        "outputs": [
            {
                "id": "0",
                "name": "HTTP output plugin",
                "plugin": "output_http.so",
                "args": " --www /www/webcam/ --port 1234"
            }
        ]
    }
    


    this is the script that launch mjpg-streamer in openwrt :

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    #!/bin/sh /etc/rc.common
    # Copyright (C) 2009-2012 OpenWrt.org
    START=50
    SERVICE_DAEMONIZE=1
    SERVICE_WRITE_PID=1
    PROG=/usr/bin/mjpg_streamer
    error() {
        echo "${initscript}:" "$@" 1>&2
    }
    section_enabled() {
        config_get_bool enabled "$1" 'enabled' 0
        [ $enabled -gt 0 ]
    }
    start_instance() {
        local s="$1"
        section_enabled "$s" || return 1
        config_get device "$s" 'device'
        config_get resolution "$s" 'resolution'
        config_get fps "$s" 'fps'
        config_get www "$s" 'www'
        config_get port "$s" 'port'
        [ -c "$device" ] || {
            error "device '$device' does not exist"
            return 1
        }
        service_start /usr/bin/mjpg_streamer --input "input_uvc.so --device $device --fps $fps --resolution $resolution" --output "output_http.so --www $www --port $port"
    }
    stop_instance() {
        local s="$1"
        section_enabled "$s" || return 1
        service_stop /usr/bin/mjpg_streamer
    }
    start() {
        config_load 'mjpg-streamer'
        config_foreach start_instance 'mjpg-streamer'
    }
    stop() {
        config_load 'mjpg-streamer'
        config_foreach stop_instance 'mjpg-streamer'
    }
    
     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks