Linux Timelapse

mit Motion

Config

/etc/default/motion
start_motion_daemon=yes
/etc/motion/motion.conf
videodevice /dev/video1
width 1280
height 720
quality 90
snapshot_interval 5
target_dir /tmp/motion
snapshot_filename %s
webcam_port 0
control_port 0

Create Timelapse Video

Das Paket ffmpeg ist jetzt unter libav-tools zu finden

apt-get install libav-tools
timelapse.sh
# change to motion storage
cd /tmp/motion
 
# create temp dir if not exists
if [ ! -d "./tmp/" ]; then
  mkdir ./tmp/
fi
 
# clear temp dir
rm ./tmp/*
 
# copy all captured images to temp dir, an rename it to 00000.jpg
x=1; for i in *.jpg; do counter=$(printf %06d $x); cp "$i" ./tmp/img"$counter".jpg; x=$(($x+1)); done
 
# acvonv=ffmpeg
avconv -r 30 -i ./tmp/img%06d.jpg -s hd720 -vcodec libx264 time-lapse.mp4
 
# clear temp dir
rm ./tmp/*

Live Image in Browser

Läd einmal pro Sekunde das angegebende Bild neu.

webcam.html
<html>
<body>
<style>
* { box-sizing: border-box; }
html, body { height: 100%; width: 100%; margin: 0; padding: 0; }
img { max-width: 100%; max-height: 100%; }
</style>
 
<img id="last"/>
<script>
  function setLastImg() {
    document.getElementById('last').src = "file:///tmp/motion/lastsnap.jpg?" + new Date().getTime();
  }  
  setLastImg();
  setInterval(setLastImg, 1000);
</script>
</body>
</html>
pub/linux-timelapse.txt · Zuletzt geändert: 2014/06/10 11:20 von Marco Krage