-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscreengrab.py
18 lines (16 loc) · 878 Bytes
/
screengrab.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import csv
import ffmpeg
from pathvalidate import sanitize_filename
#imports csv, ffmpeg-python, sanatize_filename
with open ('cameras.csv') as cameras: #opens the csv file
reader = csv.reader(cameras) #reads csv file
for row in reader: #for each row in the csv...
rtsp = row[1] #the second column of the row is now keyed as rtsp
name = row[0] #the firest column of the row is now keyed as name
camera = sanitize_filename(name) #name is now sanitized for use as a filename and called camera
(
ffmpeg #call ffmpeg
.input(rtsp, ss=.05) #input the second column of the row, and the amount of time into the video at which to grab a screenshot
.output(camera + '.png', vframes=1) #output a sanitizedfile name.png, and the amount of frames desired
.run() #run ffmpeg
)