OpenWrt Forum Archive

Topic: mjpg_streamer to start at boot

The content of this topic has been archived on 29 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi,

I am trying get mjpg_streamer to start at boot with my own parameters.

I have no trouble starting at boot with

/etc/init.d/mjpg-streamer enable

But am having trouble setting configs for the www path and password.

This works perfectly for what I want to do.

mjpg_streamer --input "input_uvc.so --device /dev/video0 --fps 10 --resolution 640x480" --output "output_http.so -w /www/webcam_www -c root:root --port 8080"

I assume this is done by adding to this file;

/etc/config/mjpg-streamer

config mjpg-streamer core
    option device    "/dev/video0"
    option resolution    "320x240"
    option fps        "5"
    option port    "8080"
    option enabled    "true"

But I don't know how! Using UCI?

I tried a manual edit of this file;

/etc/init.d/mjpg-streamer

#!/bin/sh /etc/rc.common
# Copyright (C) 2009 OpenWrt.org
START=50

SSD=start-stop-daemon
NAME=mjpg_streamer
PIDF=/var/run/$NAME.pid
PROG=/usr/bin/$NAME

start() {
    config_load mjpg-streamer
    config_get device core device
    config_get resolution core resolution
    config_get fps core fps
    config_get port core port
    config_get_bool enabled core enabled
    [ $enabled -gt 0 -a -c $device ] && sleep 3 && $SSD -S -m -p $PIDF -q -x $PROG -- --input "input_uvc.so --device $device --fps $fps --resolution $resolution" --output "output_http.so --port $port" &
}

stop() {
    $SSD -K -p $PIDF
}

To add this; (only added "-w /web/webcam_www" and "-c user:secret" to the output_http.so)

[ $enabled -gt 0 -a -c $device ] && sleep 3 && $SSD -S -m -p $PIDF -q -x $PROG -- --input "input_uvc.so --device $device --fps $fps --resolution $resolution" --output "output_http.so -w /www/webcam_www -c user:secret --port $port" &
}

But I get errors..

bump

Got it working.

roscorcoran wrote:

Got it working.

And how?

Sorry,

It turns out the text editor I was using was adding extra bytes to the file somewhere leading to corrupt files so I moved to good old notepad.

Well I probably should be using vi anyway!!

I added to my
/etc/config/mjpg-streamer

config mjpg-streamer core
    
    option path /www/webcam_www
    option password user:password

I then edited my
/etc/init.d/mjpg-streamer
adding;

config_get path core path
config_get password core password

and;

--output "output_http.so -w $path -c $password --port $port"

Hope that helps. smile

(Last edited by roscorcoran on 17 Feb 2011, 00:43)

The discussion might have continued from here.