parent
a413201ff7
commit
f57dd22b64
@ -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() |
Loading…
Reference in new issue