Files
python-2020-5-day-class/converter.py
ducoterra 09b4bc8f5b day 2
2020-11-09 21:12:58 -05:00

22 lines
830 B
Python

import subprocess
import os
import time
done_files = []
while True:
# get a list of all .mov or .gif files
movs = list(filter(lambda item: item.endswith(".mov"), os.listdir()))
print(f"Found {len(movs)} .mov files.")
gifs = list(filter(lambda item: item.endswith(".gif"), os.listdir()))
print(f"Found {len(gifs)} .gif files.")
# find files that are not already gifs and aren't default
not_done = list(filter(lambda mov: mov.replace(".mov",".gif") not in gifs and not mov.startswith("Screen Recording"), movs))
print(f"Found {len(not_done)} to convert.")
for mov in not_done:
print(f"converting {mov}. Ctrl + C to stop...")
subprocess.run(['/usr/local/bin/ffmpeg', '-i', mov, '-filter:v', 'setpts=0.5*PTS', mov.replace(".mov",".gif")], capture_output=True)
time.sleep(1)