added a broken make-a-gif functionality

main
Shoofle 2 years ago
parent a413201ff7
commit f57dd22b64
  1. 2
      index.html
  2. 26
      make_a_gif.py
  3. 13
      take_a_still.py
  4. 7
      work_log

@ -23,5 +23,7 @@
<img id="latest" src="/stills/test.jpg"/>
<p>The full catalog of still images should be seen at <a href="/stills/">http://telescopium.local/stills/</a>.</p>
<p>Telescopium's ip address is <code id="ip_address">ip addr goes here</code>.</p>
</body>
</html>

@ -0,0 +1,26 @@
#!/bin/python3
import os
from datetime import datetime
def make_it():
#filter out and sort to get only the frames we want (noon frames from the last two weeks)
files = os.listdir("/var/www/html/stills/")
twoweeks = []
now = datetime.now()
for fi in files:
f = "/var/www/html/stills/" + fi
dt = datetime.fromtimestamp(os.stat(f).st_mtime)
if (now-dt).days < 16 and dt.hour < 13 and dt.hour > 10:
twoweeks.append(f)
frames = sorted(twoweeks, key=lambda f: os.stat(f).st_mtime)
with open("/var/www/html/framelist.txt", "w+") as framelist:
framelist.write("".join(["file '" + f + "'\n" for f in frames]))
#make the actual gif
print(f"ffmpeg -r 7 -f concat -safe 0 -i /var/www/html/framelist.txt -c copy -s 1280x720 -vcodec libx264 /var/www/html/twoweeks.mp4")
print(f"convert -delay 14 -loop 0 -dispose previous {' '.join(frames)} /var/www/html/animation.gif")
if __name__ == "__main__":
make_it()

@ -1,7 +1,9 @@
#!/bin/python3
import os
import shutil
import socket
from bs4 import BeautifulSoup
from datetime import datetime
index_filename = "/var/www/html/index.html"
@ -15,6 +17,15 @@ filename = "/stills/" + os.popen("date +%+4Y-%m-%d-%Hh%Mm.jpg").read().strip()
os.system("libcamera-jpeg -o /var/www/html" + filename)
import make_a_gif
make_a_gif.make_it()
# figgure out our local ip address
s=socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect(("8.8.8.8", 80))
ip_address = s.getsockname()[0]
s.close()
#make sure that the index shows the latest one
soup = None
@ -26,5 +37,7 @@ with open(index_filename, "r") as the_file:
latest_image['src'] = filename
soup.find(id="ip_address").string = ip_address
with open(index_filename, "w") as the_file:
the_file.write(str(soup))

@ -19,3 +19,10 @@ added a listing for autoindexing the folder /var/www/html/stills/ with location
made a python script to take a picture, plus a systemd service and timer to take pictures daily! they need to be symlinked into /etc/systemd/system/
finally realized i never did `systemctl enable telescopium.timer --now` so the timer never started which is why my daily task hasn't been running. remedied.
telescopium physical has been installed in its place in the rear window. also i made it so that it prints its current ip address in the webpage.
gonna try and make it so it converts the latest month of images into a gif, at a rate of one week per second? hopefully just using imagemagick.
update: i am deep in the bowels of imagemagick and ffmpeg trying in vain to get this to work
fixed the unrelated issue where it was taking a picture every time the system rebooted. it's because i had the telescopium service enabled in addition to the timer; i disabled the service and made sure only the timer was enabled

Loading…
Cancel
Save