Anyone doing timelapse photography saving?

pete_c

Guru
I am looking to do this via Ubuntu.
 
It would be just an camera FTP to a local NAS.
 
This is weathercam related.
 
All my cams firmware now have the option of doing timelapse uploads.
 
Not looking to go to an external website for this.
 
I have been able to sort of do this with ZM but would prefer a separate Ubuntu means of doing this.
 
This post had me searching this morning.
 
Found a python script that will run on my ZM box here.
 
First installed python-imaging
 
sudo apt-get install python-imaging
 
Teknynja time lapse script
 

#!/usr/bin/python

# Number of seconds between frames:
LAPSE_TIME = 30

# Name of truetype font file to use for timestamps (should be a monospace font!)
FONT_FILENAME = "UbuntuMono-B.ttf"

# Format of timestamp on each frame
TIMESTAMP_FORMAT = "%Y-%m-%d %H:%M:%S"

# Command to batch convert mjpeg to mp4 files:
# for f in *.mjpeg; do echo $f ; avconv -r 30000/1001 -i "$f" "${f%mjpeg}mp4" 2>/dev/null ; done

import urllib
import sys, time, datetime
import StringIO
import Image, ImageDraw, ImageFont

class Camera:
def __init__(self, name, url, filename):
self.name = name
self.url = url
self.filename = filename

def CaptureImage(self):
camera = urllib.urlopen(self.url)
image_buffer = StringIO.StringIO()
image_buffer.write(camera.read())
image_buffer.seek(0)
image = Image.open(image_buffer)
camera.close()
return image

def TimestampImage(self, image):
draw_buffer = ImageDraw.Draw(image)
font = ImageFont.truetype(FONT_FILENAME, 16)
timestamp = datetime.datetime.now()
stamptext = "{0} - {1}".format(timestamp.strftime(TIMESTAMP_FORMAT), self.name)
draw_buffer.text((5, 5), stamptext, font=font)

def SaveImage(self, image):
with open(self.filename, "a+b") as video_file:
image.save(video_file, "JPEG")
video_file.flush()

def Update(self):
image = self.CaptureImage()
self.TimestampImage(image)
self.SaveImage(image)
print("Captured image from {0} camera to {1}".format(self.name, self.filename))


if __name__ == "__main__":
cameras = []
cameras.append(Camera("porch", "http://username:[email protected]<script data-cfhash='f9e31' type="text/javascript">
/* */</script>/SnapshotJPEG?Resolution=640x480&Quality=Clarity", "cam1.mjpeg"))
cameras.append(Camera("driveway", "http://username:[email protected]
/* *//SnapshotJPEG?Resolution=640x480&Quality=Clarity", "cam2.mjpeg"))
cameras.append(Camera("backyard", "http://username:[email protected]
/* *//SnapshotJPEG?Resolution=640x480&Quality=Clarity", "cam3.mjpeg"))
cameras.append(Camera("sideyard", "http://10.17.42.176/image/jpeg.cgi", "cam4.mjpeg"))
cameras.append(Camera("stairway", "http://10.17.42.175/image/jpeg.cgi", "cam5.mjpeg"))

print("Capturing images from {0} cameras every {1} seconds...".format(len(cameras), LAPSE_TIME))

try:
while (True):
for camera in cameras:
camera.Update()

time.sleep(LAPSE_TIME)

except KeyboardInterrupt:
print("\nExit requested, terminating normally")
sys.exit(0)

 
Converting to a video script which converts jpgs to mp4 video.

#!/bin/bash

echo "Removing old files..."
rm -fv *.mp4

echo "Converting files to mp4..."
for f in *.mjpeg ; do
t=${f%mjpeg}mp4
echo " Converting $f to $t"
avconv -r 30000/1001 -i "$f" -q 5 "$t" 2>/dev/null
done

echo "Done!"


 
Uploaded a test file here.  Unzip and change the extension to mp4.
 
Gonna try running this on the RPi2 that is currently running Cumulus weather software and upload the timelapse to the host service.
 
Ffmpeg will take a directory of images (Sorted by date time stamp) and create a timelapse video file. Several folks have examples on various weather forums and usually have a discussion on software and processing. I can provide links if you are interested.
 
I am interested.  I use ffmpeg today on my ZM boxes.
 
Thank you Jmltech.
 
Yeah so far the running mjpeg video made from the stills is not dinging the CPUs on the RPi2, ZM boxes or mothership (iSeries box).  The video conversion is CPU intensive.
 
Downloaded and tested WinFF for Ubuntu.  Works well.
 
The above script is working fine now on my Ubuntu 14.04 Atom based touch tablets. 
 
I also am using embedded XP on these and will try same script in XPe for my Homeseer Windows touchscreens.
 
I am looking for some free Wintel based timelapse stuff and can only find paid for software so far.
 
Hi Pete. I totally apologize for not responding. I forgot that I had replied to this thread, and ran across it today.

I'm still playing around with a python script (not finished yet) that will take a collection of images that my foscam camera ftp'ed, and make a timelapse using ffmpeg. I have the functionality of the script working. Still need to do some cleanup on the script from all the testing (I'm new to Python, so a lot of testing and debug code was inserted as I went along)

Again, sorry for not being good with with my follow-up. Not very good forum etiquette on my part.
 
Not an issue Jmitech.
 
Here haven't played much with the script other than putting it on one Kodi box for viewing.
 
Back
Top