-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathextract_frame.py
55 lines (41 loc) · 1.3 KB
/
extract_frame.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import os
all_videos = ('archery',
'breaststroke',
'crossbow',
'dance',
'dodge',
'fly',
'horse_riding',
'run',
'skydiving',
'waving_weapon')
ucf_videos = ('archery',
'horse_riding',
'run',
'breaststroke',
'skydiving')
new_videos = ('crossbow',
'dance',
'dodge',
'fly',
'waving_weapon')
def process_videos(video_list=all_videos):
if not os.path.exists('./frames'):
os.makedirs('./frames')
for video in video_list:
if os.path.exists('./' + video):
for i in range(1, 11):
video_name = './' + video + '/' + video + '_' + str(i) + '.mp4'
destination = './frames/' + video + '_'
get_frame(video_name, destination)
def get_frame(video, directory):
"""
extract frames from videos with given FPS 15
"""
fps = '20'
dest = video[-5:-4] # The folder that the frame images will end up in
os.system('ffmpeg -i ' + video + ' -vf scale=240:240' + ' -r ' + fps + ' ' + directory + dest + '_%03d.png')
def main():
process_videos()
if __name__ == '__main__':
main()