#!/bin/bash

inotifywait -m /var/www/camera.stoobz.uk/public_html/raw_captures -e create -e moved_to -r  | while read -r directory action file; do
    if [[ "$file" =~ .*264$ ]]; then
	    ffmpeg -r 25 -fflags +genpts -i ${directory}${file} -c copy /var/www/camera.stoobz.uk/public_html/video/${file}.mp4 2>&1
   rm ${directory}${file} 2>&1	    
    fi
done
