1 -- Copyright 2014 Roger D <rogerdammit@gmail.com>
2 -- Licensed to the public under the Apache License 2.0.
4 m = Map("mjpg-streamer", "MJPG-streamer", translate("mjpg streamer is a streaming application for Linux-UVC compatible webcams"))
6 --- General settings ---
8 section_gen = m:section(TypedSection, "mjpg-streamer", translate("General"))
9 section_gen.addremove=false
10 section_gen.anonymous=true
12 enabled = section_gen:option(Flag, "enabled", translate("Enabled"), translate("Enable MJPG-streamer"))
14 input = section_gen:option(ListValue, "input", translate("Input plugin"))
15 input:depends("enabled", "1")
16 input:value("uvc", "UVC")
17 ---input:value("file", "File")
18 input.optional = false
20 output = section_gen:option(ListValue, "output", translate("Output plugin"))
21 output:depends("enabled", "1")
22 output:value("http", "HTTP")
23 output:value("file", "File")
24 output.optional = false
27 --- Plugin settings ---
29 s = m:section(TypedSection, "mjpg-streamer", translate("Plugin settings"))
33 s:tab("output_http", translate("HTTP output"))
34 s:tab("output_file", translate("File output"))
35 s:tab("input_uvc", translate("UVC input"))
36 ---s:tab("input_file", translate("File input"))
39 --- Input UVC settings ---
41 this_tab = "input_uvc"
43 device = s:taboption(this_tab, Value, "device", translate("Device"))
44 device.default="/dev/video0"
45 --device.datatype = "device"
46 device:value("/dev/video0", "/dev/video0")
47 device:value("/dev/video1", "/dev/video1")
48 device:value("/dev/video2", "/dev/video2")
49 device.optional = false
51 resolution = s:taboption(this_tab, Value, "resolution", translate("Resolution"))
52 resolution.default = "640x480"
53 resolution:value("320x240", "320x240")
54 resolution:value("640x480", "640x480")
55 resolution:value("800x600", "800x600")
56 resolution:value("864x480", "864x480")
57 resolution:value("960x544", "960x544")
58 resolution:value("960x720", "960x720")
59 resolution:value("1280x720", "1280x720")
60 resolution:value("1280x960", "1280x960")
61 resolution:value("1920x1080", "1920x1080")
62 resolution.optional = true
64 fps = s:taboption(this_tab, Value, "fps", translate("Frames per second"))
65 fps.datatype = "and(uinteger, min(1))"
69 yuv = s:taboption(this_tab, Flag, "yuv", translate("Enable YUYV format"), translate("Automatic disabling of MJPEG mode"))
71 quality = s:taboption(this_tab, Value, "quality", translate("JPEG compression quality"), translate("Set the quality in percent. This setting activates YUYV format, disables MJPEG"))
72 quality.datatype = "range(0, 100)"
74 minimum_size = s:taboption(this_tab, Value, "minimum_size", translate("Drop frames smaller then this limit"),translate("Set the minimum size if the webcam produces small-sized garbage frames. May happen under low light conditions"))
75 minimum_size.datatype = "uinteger"
77 no_dynctrl = s:taboption(this_tab, Flag, "no_dynctrl", translate("Don't initialize dynctrls"), translate("Do not initialize dynctrls of Linux-UVC driver"))
79 led = s:taboption(this_tab, ListValue, "led", translate("Led control"))
80 led:value("on", translate("On"))
81 led:value("off", translate("Off"))
82 led:value("blink", translate("Blink"))
83 led:value("auto", translate("Auto"))
87 --- Output HTTP settings ---
89 this_tab = "output_http"
91 port=s:taboption(this_tab, Value, "port", translate("Port"), translate("TCP port for this HTTP server"))
92 port.datatype = "port"
93 port.placeholder = "8080"
95 enable_auth = s:taboption(this_tab, Flag, "enable_auth", translate("Authentication required"), translate("Ask for username and password on connect"))
96 enable_auth.default = false
98 username = s:taboption(this_tab, Value, "username", translate("Username"))
99 username:depends("enable_auth", "1")
100 username.optional = false
102 password = s:taboption(this_tab, Value, "password", translate("Password"))
103 password:depends("enable_auth", "1")
104 password.password = true
105 password.optional = false
106 password.default = false
108 www = s:taboption(this_tab, Value, "www", translate("WWW folder"), translate("Folder that contains webpages"))
109 www.datatype = "directory"
110 www.default = "/www/webcam/"
117 <style media="screen" type="text/css">
119 display: inline-block;
123 line-height: 1.428571429;
124 background-color: #fff;
125 border: 1px solid #ddd;
127 -webkit-transition: all .2s ease-in-out;
128 transition: all .2s ease-in-out;
135 <img id="video_preview" class="img-preview" onerror="on_error()" onload="on_load()"/>
136 <p id="stream_status" style="text-align: center; color: orange; font-weight:bold;">Stream unavailable</p>
139 <script type="text/javascript">
141 function init_stream() {
142 console.log('init_stream');
146 function _start_stream() {
147 console.log('_start_stream');
149 port = document.getElementById('cbid.mjpg-streamer.core.port').value
151 if (document.getElementById('cbid.mjpg-streamer.core.enable_auth').checked) {
152 user = document.getElementById('cbid.mjpg-streamer.core.username').value
153 pass = document.getElementById('cbid.mjpg-streamer.core.password').value
154 login = user + ":" + pass + "@"
159 img = document.getElementById('video_preview');
160 img.src = 'http://' + login + location.hostname + ':' + port + '/?action=snapshot';
163 function start_stream() {
164 console.log('start_stream');
166 setTimeout(function() { _start_stream(); }, 500);
169 function on_error() {
170 console.log('on_error');
172 img = document.getElementById('video_preview');
173 img.style.display = 'none';
175 stream_stat = document.getElementById('stream_status');
176 stream_stat.style.display = 'block';
182 console.log('on_load');
184 img = document.getElementById('video_preview');
185 img.style.display = 'block';
187 stream_stat = document.getElementById('stream_status');
188 stream_stat.style.display = 'none';
196 preview = s:taboption(this_tab, DummyValue, "_dummy", html)
197 preview:depends("output", "http")
199 --- Output file settings ---
201 this_tab = "output_file"
203 folder=s:taboption(this_tab, Value, "folder", translate("Folder"), translate("Set folder to save pictures"))
204 folder.placeholder="/tmp/images"
205 folder.datatype = "directory"
207 --mjpeg=s:taboption(this_tab, Value, "mjpeg", translate("Mjpeg output"), translate("Check to save the stream to an mjpeg file"))
209 delay=s:taboption(this_tab, Value, "delay", translate("Interval between saving pictures"), translate("Set the interval in millisecond"))
210 delay.placeholder="5000"
211 delay.datatype = "uinteger"
213 ringbuffer=s:taboption(this_tab, Value, "ringbuffer", translate("Ring buffer size"), translate("Max. number of pictures to hold"))
214 ringbuffer.placeholder="10"
215 ringbuffer.datatype = "uinteger"
217 exceed=s:taboption(this_tab, Value, "exceed", translate("Exceed"), translate("Allow ringbuffer to exceed limit by this amount"))
218 exceed.datatype = "uinteger"
220 command=s:taboption(this_tab, Value, "command", translate("Command to run"), translate("Execute command after saving picture. Mjpg-streamer parse the filename as first parameter to your script."))
222 link=s:taboption(this_tab, Value, "link", translate("Link newest picture to fixed file name"), translate("Link the last picture in ringbuffer to fixed named file provided."))