20 lines
649 B
Python
20 lines
649 B
Python
|
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)
|
||
|
os.system(cmd)
|
||
|
event_no += 1
|
||
|
|