-
Notifications
You must be signed in to change notification settings - Fork 0
/
thumbnail_gen.py
42 lines (36 loc) · 1.07 KB
/
thumbnail_gen.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
import os
import sys
import subprocess
def thumb_dir(directory): #thumbnails of complete directory
mypath = directory
try:
os.mkdir(mypath + '/thumbs/')
except:
print()
for (dirpath, dirnames, filenames) in os.walk(mypath):
print(filenames)
for file in filenames:
if(file.endswith('.mp4')):
video_input_path = mypath + file
img_output_path = mypath + '/thumbs/' + file + '.jpg'
subprocess.call(['ffmpeg', '-i', video_input_path, '-ss', '00:00:10.000', '-vframes', '1', img_output_path])
break
def thumb_curr(): #thumbnails of complete directory
mypath = os.getcwd() + '/'
try:
os.mkdir(mypath + 'thumbs/')
except:
print()
for (dirpath, dirnames, filenames) in os.walk(mypath):
print(filenames)
for file in filenames:
if(file.endswith('.mp4')):
video_input_path = mypath + file
img_output_path = mypath + 'thumbs/' + file + '.jpg'
subprocess.call(['ffmpeg', '-i', video_input_path, '-ss', '00:00:10.000', '-vframes', '1', img_output_path])
break
try:
if(sys.argv[1] == 'current'):
thumb_curr()
except:
print()