Technology / Software / 

25 Sep 2016

Linux "motion" output options/conversion

General Output Config Notes

Filename format is specified in /etc/motion/motion.conf

Documentation: http://www.lavrsen.dk/foswiki/bin/view/Motion/ConfigOptionPictureFilename

Default values:

snapshot_filename %v-%Y%m%d%H%M%S-motion picture_filename %v-%Y%m%d%H%M%S-%q

this means:
[event]-[year][month][day][hour][minute][second]-[frame]

However, the “event” numbers don’t seem to be particularly useful… and in fact the ‘old style’ naming scheme, which organizes the output by subdirs, is probably better than the default one (changed laptop config files to it, 9/26/2016)

To remove event numbers from files:

for file in *jpg; do mv "$file" "${file:3}"; done

(But note: this relies on shell expansion so it may have a limit to the number of files it can work on)

Making a Movie with ffmpeg

Basic command:

Bash ffmpeg -framerate 30 -i '%*.jpg' -s:v 1920x1080 -c:v libx264 -r 30 ./motion.mp4

This should use the default sort order, same as ls: if the ‘event’ numbering is removed it will be chronological.

To make a video from Raspberry Pi “motion” output, run:

Bash ffmpeg -framerate 30 -i 'rpi0-%*.jpg' -s:v 1920x1080 -c:v libx264 -r 30 ./rpi0-`date -I`.mp4

This assumes that files are prefixed by “rpi0” … for other device IDs need to change, obviously, or better yet would be to write a wrapper script for multiple devices to run periodically (daily?).

The motion detection script should be touch-ing /tmp/motion_detected whenever it detects anything. This is apparently how the software knows how long it’s been since the last motion event, and if it’s time to take another photo.