Skip to content

Instantly share code, notes, and snippets.

@dadatuputi
Created July 22, 2022 19:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dadatuputi/1b54e7307f64b39defa8b80230a51fa2 to your computer and use it in GitHub Desktop.
Save dadatuputi/1b54e7307f64b39defa8b80230a51fa2 to your computer and use it in GitHub Desktop.
Convert Amcrest images to Timelapse Video
import os
import shutil
# for root, dirs, files in os.walk('G:\\', topdown=False):
# if 'dav' in root:
# continue
# for name in files:
# if '.jpg' in name:
# _full = os.path.join(root, name)
# _split = _full.split('\\')
# new_name = "{} {}{}.jpg".format(_split[1], _split[4], _split[5])
# print(new_name)
# shutil.copy(_full, 'pic\\{}'.format(new_name))
# #print(os.path.join(root, name))
# #for name in dirs:
# # print(os.path.join(root, name))
c = 0
last_time = 0
last_day = 0
for root, dirs, files in os.walk('pic'):
for name in files:
if '.jpg' in name:
_time = int((name.split(' ')[1]).split('.')[0])
_day = int((name.split(' ')[0]).split('-')[2])
if _day == last_day and _time - last_time < 5:
continue
shutil.copy(os.path.join(root, name), 'pic2\\img-{}.jpg'.format(str(c).zfill(4)))
last_time = _time
last_day = _day
c+=1
# ffmpeg -framerate 60 -f image2 -i img-%4d.jpg test.mkv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment