Welcome to the Cumulus Support forum.

Latest Cumulus MX V3 release 3.28.6 (build 3283) - 21 March 2024

Cumulus MX V4 beta test release 4.0.0 (build 4018) - 28 March 2024

Legacy Cumulus 1 release v1.9.4 (build 1099) - 28 November 2014 (a patch is available for 1.9.4 build 1099 that extends the date range of drop-down menus to 2030)

Download the Software (Cumulus MX / Cumulus 1 and other related items) from the Wiki

Time Lapse WeatherCam

Hardware/software/hints and tips/discussion/webcam links etc
User avatar
pete_c
Posts: 228
Joined: Wed 12 Oct 2011 11:22 pm
Weather Station: Davis Vue-Pro2 - Fine Offset
Operating System: W2003-XPSP3-Linux
Location: Time Traveler

Time Lapse WeatherCam

Post by pete_c »

Not sure if anyone posted this. I found a Python script that will do an easy Time Lapse on an RPi2.

http://www.teknynja.com/2013/05/time-la ... twork.html

1 - sudo apt-get install python-imaging

2 - talicam.py script

Code: Select all

#!/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:password@10.17.42.172/SnapshotJPEG?Resolution=640x480&Quality=Clarity", "cam1.mjpeg"))
    cameras.append(Camera("driveway", "http://username:password@10.17.42.174/SnapshotJPEG?Resolution=640x480&Quality=Clarity", "cam2.mjpeg"))
    cameras.append(Camera("backyard", "http://username:password@10.17.42.173/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)
3 - mjpeg2mp4 converter

Code: Select all

#!/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!"
Here put the above two in my home directory and added one font to the directory.

Works well.
- Pete
Automator
User avatar
nitrx
Posts: 1297
Joined: Sun 13 Dec 2009 1:21 pm
Weather Station: WH1080
Operating System: Windows 10
Location: Apeldoorn The Netherlands
Contact:

Re: Time Lapse WeatherCam

Post by nitrx »

Thanks I was looking for something like this on my Pi B2 , I only wonder how they start and can be scheduled at first I shall try to use it with my foscam 8904.
User avatar
pete_c
Posts: 228
Joined: Wed 12 Oct 2011 11:22 pm
Weather Station: Davis Vue-Pro2 - Fine Offset
Operating System: W2003-XPSP3-Linux
Location: Time Traveler

Re: Time Lapse WeatherCam

Post by pete_c »

I currently utilize Webmin to manage my CumulusMX Raspberry Pi 2.

The Webmin interface allows for easy management access of the RPi2.

You can configure Cron / Upstart stuff with Webmin or just manually run stuff with it.

Webmin can be installed via SSH like this:

Code: Select all

1 - wget hxxp://prdownloads.sourceforge.net/webadmin/webmin_1.770_all.deb

2 - apt-get install perl libnet-ssleay-perl openssl libauthen-pam-perl libpam-runtime libio-pty-perl apt-show-versions python

3 - dpkg --install webmin_1.770_all.deb
- Pete
Automator
User avatar
nitrx
Posts: 1297
Joined: Sun 13 Dec 2009 1:21 pm
Weather Station: WH1080
Operating System: Windows 10
Location: Apeldoorn The Netherlands
Contact:

Re: Time Lapse WeatherCam

Post by nitrx »

Pete will webmin run under raspian ? And I suppose you mean http instead hxxp above ?

Ron
User avatar
pete_c
Posts: 228
Joined: Wed 12 Oct 2011 11:22 pm
Weather Station: Davis Vue-Pro2 - Fine Offset
Operating System: W2003-XPSP3-Linux
Location: Time Traveler

Re: Time Lapse WeatherCam

Post by pete_c »

Yup.

Raspbian/Wheezy is just a tweaked for the Raspberry Pi Debian Linux.

The only add is Mono for running CumulusMX.

You could test run it to see what it does to CPU utilization concurrently running CumulusMX. One camera captures shouldn't really ding the RPi2.

The instructions above are generic Debian Linux install directions.

If you are using a Wintel PC you can also install SSH and WinSCP to help you manage your RPi2.

Linux Ubuntu LTS desktop already includes SSH and a explorer like drive / remote device access application (files).

The simple way to run the above Python script is just to put it in a start cron job. You can create a push button or automatic script to convert and FTP the video.

I tried to FTP the webcam timelapse video last night here and my host service did not accept it. It is small.
- Pete
Automator
User avatar
nitrx
Posts: 1297
Joined: Sun 13 Dec 2009 1:21 pm
Weather Station: WH1080
Operating System: Windows 10
Location: Apeldoorn The Netherlands
Contact:

Re: Time Lapse WeatherCam

Post by nitrx »

Thanks for the feedback i give it tomorrow a try.
Ron
User avatar
pete_c
Posts: 228
Joined: Wed 12 Oct 2011 11:22 pm
Weather Station: Davis Vue-Pro2 - Fine Offset
Operating System: W2003-XPSP3-Linux
Location: Time Traveler

Re: Time Lapse WeatherCam

Post by pete_c »

Copied over the time lapse script over to the CumulusMX RPi2.

Have it starting out as a cron job.

cd /video && python /video/talicam.py

Not really hitting the CPU on the RPi2.

If concerned about space you can run the python script on a share from another computer.

Here goofing around sending the video over to a Kodi box for viewing.

Noticed that avconv in the scriptmjpeg2mp4 doesn't work until you install avconv (unless you have already done so).

To install avconv do the following:

apt-get install libavcodec-extra-52
apt-get install libav-tools
- Pete
Automator
User avatar
nitrx
Posts: 1297
Joined: Sun 13 Dec 2009 1:21 pm
Weather Station: WH1080
Operating System: Windows 10
Location: Apeldoorn The Netherlands
Contact:

Re: Time Lapse WeatherCam

Post by nitrx »

Hi Pete installed Webmin (nice enviroment) the capture script talicam.py works it makes an *.mpjg file but not an mp4 file I dont now how the mjpeg2mp4 is run

furthermore
To install avconv do the following:

apt-get install libavcodec-extra-52
apt-get install libav-tools
libav-tools were installed but apt-get install libavcodec-extra-52 gives libavcodec-extra-52 is not availble and some errors about missing ...

Anyway thanks so far. PS the text on the images is white when its daylight so hardy to read ...
Ron
User avatar
pete_c
Posts: 228
Joined: Wed 12 Oct 2011 11:22 pm
Weather Station: Davis Vue-Pro2 - Fine Offset
Operating System: W2003-XPSP3-Linux
Location: Time Traveler

Re: Time Lapse WeatherCam

Post by pete_c »

but apt-get install libavcodec-extra-52 gives libavcodec-extra-52 is not availble and some errors about missing ...

Try..

apt-get install libavcodec-extra-51
or
apt-get install libavcodec-extra-53
or
apt-get install libavcodec-extra-54

One of those should work.

mjpeg2mp4 is just a bash script so you would run it like so:

./mjpeg2mp4

You will get an error until you fix avconv.
- Pete
Automator
User avatar
nitrx
Posts: 1297
Joined: Sun 13 Dec 2009 1:21 pm
Weather Station: WH1080
Operating System: Windows 10
Location: Apeldoorn The Netherlands
Contact:

Re: Time Lapse WeatherCam

Post by nitrx »

installed apt-get install libavcodec-extra-53 but still no joy stupid linux :?
User avatar
pete_c
Posts: 228
Joined: Wed 12 Oct 2011 11:22 pm
Weather Station: Davis Vue-Pro2 - Fine Offset
Operating System: W2003-XPSP3-Linux
Location: Time Traveler

Re: Time Lapse WeatherCam

Post by pete_c »

While I have a couple of first generation RPI's I have not done anything with them. IE: I can only confirm that this work on my RPi2's which are:

Operating system:Debian Linux 7.8

uname -a
Linux ICS-Cumulus 4.1.7-v7+ #817 SMP PREEMPT Sat Sep 19 15:32:00 BST 2015 armv7l GNU/Linux

mono -V
Mono JIT compiler version 3.12.1 (tarball Fri Mar 6 23:28:08 UTC 2015)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. http://www.mono-project.com

python
Python 2.7.3 (default, Mar 18 2014, 05:13:23)

avconv /?
avconv version 9.14-6:9.14-1rpi1rpi1, Copyright (c) 2000-2014 the Libav developers
built on Jul 22 2014 15:08:12 with gcc 4.6 (Debian 4.6.3-14+rpi1)


Cron:
Command python /video/talicam.py
CPU 0.4 %

Manual running of bash script:
Command avconv -r 30000/1001 -i cam1.mjpeg -q 5 cam1.mp4
CPU 356 %


What errors do you see when running the avconv bash script?
- Pete
Automator
User avatar
nitrx
Posts: 1297
Joined: Sun 13 Dec 2009 1:21 pm
Weather Station: WH1080
Operating System: Windows 10
Location: Apeldoorn The Netherlands
Contact:

Re: Time Lapse WeatherCam

Post by nitrx »

I've all the version the same as you have I put the files in /home/pi/Video

the py script works fine but

mjpeg2mp4 with ./mjeg2mp4 gives no such file or directory

sudo ./mjpeg2mp4 gives command not found I give the commands frome a terminal on the pi..
I see you've edit your post I will make another mjpeg later (had deleted the file..)
User avatar
nitrx
Posts: 1297
Joined: Sun 13 Dec 2009 1:21 pm
Weather Station: WH1080
Operating System: Windows 10
Location: Apeldoorn The Netherlands
Contact:

Re: Time Lapse WeatherCam

Post by nitrx »

pete_c wrote:
Manual running of bash script:
Command avconv -r 30000/1001 -i cam1.mjpeg -q 5 cam1.mp4
CPU 356 %[/b]

What errors do you see when running the avconv bash script?
this gives Unrecognized option '5'.
Error splitting the argument list: Option not found
pi@raspberry ~/Video $
User avatar
pete_c
Posts: 228
Joined: Wed 12 Oct 2011 11:22 pm
Weather Station: Davis Vue-Pro2 - Fine Offset
Operating System: W2003-XPSP3-Linux
Location: Time Traveler

Re: Time Lapse WeatherCam

Post by pete_c »

Have you made the bash script executable?

IE: chmod +x mjpeg2mp4

You can do this with WinSCP too.
- Pete
Automator
User avatar
nitrx
Posts: 1297
Joined: Sun 13 Dec 2009 1:21 pm
Weather Station: WH1080
Operating System: Windows 10
Location: Apeldoorn The Netherlands
Contact:

Re: Time Lapse WeatherCam

Post by nitrx »

Yes it has 755 permissions maybe you can have a look in webmin I can make an account and forward you to my pi ?
Post Reply