There's a couple of python scripts. One to capture pictures every 5-minutes (or your choice) and one to process into a timelapse move and upload to your website of choice using FTP.
Collector Python Script
Code: Select all
import time
from urlgrabber.grabber import urlgrab
snapfile = "/home/pi/cam/snapshot"+time.strftime("%Y%m%d")+time.strftime("%H%M%S")+".jpg"
urlgrab("https://admin.meteobridge.com/cam/<your unique code>/camplus.jpg", snapfile)
Timelapse Python Script
Code: Select all
import datetime
import os
import glob
import ftplib
from os import system
fileList = glob.glob("/home/pi/cam/*.mp4")
# remove old file before re-creating
for filePath in fileList:
try:
os.remove(filePath)
except:
print("Error while deleting file : ". filePath)
# create the .mp4. FPS ultimately determines the length/speed of the movie. 5min = 12 photos/hr = max 144 photos/day. 12 fps = 12 second movie.
fps = 12 # frames per second
dateraw= datetime.datetime.now()
datetimeformat = dateraw.strftime("%Y%m%d_%H:%M:00")
system('ffmpeg -r {} -f image2 -s 1706x960 -nostats -loglevel 0 -pattern_type glob -i "/home/pi/cam/snapshot*.jpg" -vcodec libx264 -crf 25 -pix_fmt yuv420p /home/pi/cam/{}.mp4'.format(fps, datetimeformat))
# ftp the .mp4 to your website
session = ftplib.FTP('ftp.yoursite.com','<userid>','<password>')
file = open('/home/pi/cam/{}.mp4'.format(datetimeformat))
session.storbinary('STOR timelapse.mp4', file)
file.close()
session.quit()
Code: Select all
import os
import glob
fileList = glob.glob("/home/pi/cam/snapshot*.jpg")
for filePath in fileList:
try:
os.remove(filePath)
except:
print("Error while deleting file : ". filePath)
Use this line:
Code: Select all
<?php //webcam option if yes
if ($webcamdevice == "yes") { echo '<a href="weather34-large-cam.php" data-lity data-title="Webcam">';echo $webcamicon2.' Webcam</a><br>';}?>
Code: Select all
<?php //webcam option if yes
if ($webcamdevice == "yes") { echo '<a href="weather34-timelapse.php" data-lity data-title="Timelapse Today">';echo $webcamicon2.' Timelapse</a><br>';}?>
Code: Select all
<?php if (!empty($videoWeatherCamURL) && $videoWeatherCamURL != ' ' && $videoWeatherCamURL != 'Null' && $videoWeatherCamURL != 'null'){?>
<iframe class="videoWeatherCamLarge" allowfullscreen webkitallowfullscreen mozallowfullscreen src="<?php echo $videoWeatherCamURL;?>" frameborder="0"></iframe>
<?php } else {?>
<img src="<?php echo $webcamurl;?>?v=<?php echo date('YmdGis');?>" alt="weathercam" class="webcamlarge">
<?php }?>
Code: Select all
<video controls="controls" class="webcamlarge">
<source src="timelapse.mp4" type="video/mp4">
</video>
Enjoy.