OpenWRT MJPGstreamer

sezione dedicata ai sistemi operativi alternativi Open Source

OpenWRT MJPGstreamer

Messaggio da leggereda root » 17/04/2015, 4:11

Since mjpg-streamer documentation sucks, I'm putting here some useful information about it:


- to remotely capture a snapshot image from mjpg-streamer and save it to a jpg format:

wget http://user:password@mjpg-streamer-address:port/?action=snapshot -O output.jpg

- to remotely capture a streaming video from mjpg-streamer and save it to a file (mjpg format) format (open it with VLC):

wget http://user:password@mjpg-streamer-address:port/?action=stream -O output.mjpg

- to remotely capture a streaming video from mjpg-streamer and save it to a file (mjpg format) with a timestamp into the filename (open it with VLC):

now=$(date +"%Y-%m-%d----%H-%M-%S") ; wget http://user:password@mjpg-streamer-address:port/?action=stream -O output$now.mjpg

filename example: "output2015-01-13----01-10-13.mjpg"


- to put an overlay "time" on streaming video this is the mjpg-streamer "/www/webcam/index.html" modified file:

<html>
<head>
<title>MJPG-Streamer</title>
<style>
.container { position:relative; }
.container video {
position:relative;
z-index:0;
}


.overlay {
position:absolute;
top:0;
left:0;
z-index:1;
}
</style>
</head>
<body>
<div class="container">
<img src="/?action=stream"/>
<div class="overlay">
<div style="position:absolute;width:290px;font-size:200%;font-weight:bold; background-color:lightgray; filter:alpha(opacity=60); opacity:.6;" id="time_span"> </div>


</div>
</div>

<script type='text/javascript'>
timer();


function timer(){
var now = new Date,
hours = now.getHours(),
ampm = hours<=11 ? ' AM' : ' PM'
minutes = now.getMinutes(),
seconds = now.getSeconds(),
t_str = "&nbsp;" + [hours,
(minutes < 10 ? "0" + minutes : minutes),
(seconds < 10 ? "0" + seconds : seconds)]
.join(':') + ampm + "&nbsp;&nbsp;&nbsp;&nbsp;";
document.getElementById('time_span').innerHTML = t_str;
setTimeout(timer,1000);
}


</script>

</body>
</html>



- to launch mjpg-streamer from commandline:

mjpg_streamer -i "./input_uvc.so -f 5 -r 640x480" -o "./output_http.so -w ./www"

note: this command does not use the /etc/config/mjpg-streamer configuration file

or:

/etc/init.d/mjpg-streamer start

note: this command uses the /etc/config/mjpg-streamer configuration file


"/etc/config/mjpg-streamer" configuration file:

config mjpg-streamer 'core'
option enabled '1'
option input 'uvc'
option output 'http'
option device '/dev/video0'
option resolution '640x480'
option fps '5'
option www '/www/webcam'
option port '8080'
option username 'user'
option password 'password'



- to enable mjpg-streamer autostart at bootup:

/etc/init.d/mjpg-streamer enable


- script to remotely capture a streaming video for one hour from mjpg-streamer and save it to a file (mjpg format) with a timestamp into the filename, than stops and starts another recording, and so on (infinite loop)

#!/bin/bash
while :
do
now=$(date +"%Y-%m-%d----%H-%M-%S")
wget http://user:password@mjpg-streamer-addr ... ion=stream -O output$now.mjpg &
sleep 3600
ps -ef | grep wget | awk '{print $2}' | xargs kill
done
Maurizio
Avatar utente
root
Amministratore
 
Messaggi: 347
Iscritto il: 10/04/2012, 10:55
Località: Ovada

Torna a OpenWRT e sistemi operativi vari

Chi c’è in linea

Visitano il forum: Nessuno e 1 ospite