-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdumpframes.py
54 lines (46 loc) · 1.38 KB
/
dumpframes.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
# Dump frames from multiple video files
# Usage: dumpframes.py path_to_videos
# Prerequisites: Python 3 and ffmpeg
# v0.95
import os
import sys
import subprocess
def main():
os.system('clear')
pathffmpeg="/bin/ffmpeg"
if not os.path.isfile(pathffmpeg):
print("ffmpeg maybe not installed? (" + pathffmpeg + ")")
print("Change path in script.")
sys.exit()
if len(sys.argv) != 2:
print("Invalid number of arguments.")
sys.exit()
path=sys.argv[1]
if path == "-h":
print("Usage: python3 dumpframes.py /home/John/videos")
sys.exit()
if not os.path.exists(path):
sys.exit()
for filename in os.listdir(path):
filepath = os.path.join(path,filename)
try:
outpath=str(filepath) + str(".iframes")
os.mkdir(outpath)
print("Output folder created: " + outpath)
except FileExistsError:
print("Output folder already excist.")
sys.exit()
if os.path.isfile(filepath):
print("Passed file check ("+str(filepath) + ")")
outfile=str(outpath) + str("/thumb%000004d.png")
print("Outfile: " + outfile)
try:
print("Try dumping: " + filepath)
subprocess.check_call([r"/bin/ffmpeg", "-i", filepath, outfile, "-hide_banner"])
print("Successfully dumped iframes (" + filepath + ")")
except subprocess.CalledProcessError as e:
print("Failed dumping iframes (" + filepath +")")
print(e)
sys.exit()
if __name__ == '__main__':
main()