You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
987 B
27 lines
987 B
2 years ago
|
#!/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()
|