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.

19 lines
649 B

from datetime import datetime
import os
import sys
_, path = sys.argv
TIME_FORMAT = "%Y-%m-%d-%H-%M-%S"
clip_start = datetime.strptime(path[7:26], TIME_FORMAT)
event_no = 1
for line in open(path):
frame, raw_start, raw_end = line.strip().split(";")
event_start, event_end = datetime.strptime(raw_start, TIME_FORMAT), datetime.strptime(raw_end, TIME_FORMAT)
cmd = "ffmpeg -ss %s -i %s -t %s -vcodec copy extracted-%s-%d.mp4" % (
event_start-clip_start, path.replace(".events", ".mp4"), event_end-event_start,
clip_start.strftime(TIME_FORMAT), event_no)
print("executing:", cmd)
event_no += 1