Last active
December 16, 2015 09:49
-
-
Save jl2/5416145 to your computer and use it in GitHub Desktop.
Download the ABasin web cam images and make a time lapse movie out of them. In Python and an attempt at Common Lisp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (ql:quickload "drakma") | |
| (defun download-image (url idx) | |
| (let* | |
| ((outfname (format nil "lisp_images/~6,'0d.jpg" idx)) | |
| (instream (drakma:http-request url :want-stream t :force-binary t)) | |
| (buf (make-array 4096 :element-type (stream-element-type instream)))) | |
| (with-open-file (outstream outfname | |
| :direction :output | |
| :if-exists :supersede | |
| :element-type '(unsigned-byte 8)) | |
| (loop for pos = (read-sequence buf instream) | |
| while (plusp pos) do | |
| (write-sequence buf outstream :end pos))))) | |
| (download-image "http://www.arapahoebasin.com/ABasin/assets/images/webcams/webcam5/abasincam5.jpg" 0) | |
| (let ((cnt 0)) | |
| (multiple-value-bind | |
| (second minute hour date month year day-of-week dst-p tz) | |
| (get-decoded-time) | |
| (if (and (> hour 7) (and (< hour 17) (< minute 5))) | |
| (progn | |
| (download-image "http://www.arapahoebasin.com/ABasin/assets/images/webcams/webcam5/abasincam5.jpg" cnt) | |
| (setf cnt (+ cnt 1))) | |
| (if (and (= hour 17) (> minute 5)) | |
| (let ((command (format nil "ffmpeg -i lisp_images/%6d.jpg -r 30 -b:v 8000k ~2,'0d-~2,'0d-~d.mpg" month date year))) | |
| (sleep (* 5 60)) | |
| ))) | |
| "http://www.arapahoebasin.com/ABasin/assets/images/webcams/webcam5/abasincam5.jpg" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import httplib2 | |
| import time | |
| cnt = 1 | |
| h = httplib2.Http() | |
| while True: | |
| resp, content = h.request("http://www.arapahoebasin.com/ABasin/assets/images/webcams/webcam5/abasincam5.jpg") | |
| with open("images/%06d.jpg"%cnt, "wb") as outf: | |
| outf.write(content) | |
| cnt += 1 | |
| if cnt == 144: | |
| os.system("ffmpeg -i images/%6d.jpg -r 30 -b:v 8000k video.mp4") | |
| cnt = 0 | |
| time.sleep(5*60) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment