-
Notifications
You must be signed in to change notification settings - Fork 34
/
framemd5.py
executable file
·65 lines (60 loc) · 1.86 KB
/
framemd5.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
56
57
58
59
60
61
62
63
64
#!/usr/bin/env python3
'''
Creates framemd5 sidecars on all mov/mkv files in all subfolders beneath your input.
If the input is a file, then framemd5.py will just generate a sidecar for this one file.
'''
import subprocess
import os
import argparse
import ififuncs
def parse_args():
'''
Parse command line arguments.
'''
parser = argparse.ArgumentParser(
description='Creates framemd5 sidecars on all mov/mkv files in all subfolders beneath your input.'
' If the input is a file, then framemd5.py will just generate a sidecar for this one file.'
)
parser.add_argument(
'-i',
help='full path of input file or directory', required=True
)
parsed_args = parser.parse_args()
return parsed_args
def main():
'''
Simple recursive process that makes framemd5 sidecar reports.
'''
ififuncs.check_existence(['ffmpeg'])
args = parse_args()
source = args.i
fmd5 = source + '_source.framemd5'
if os.path.isfile(source):
cmd = [
'ffmpeg',
'-i',
source,
'-f',
'framemd5',
'-an',
fmd5
]
subprocess.call(cmd)
else:
for root, _, filenames in os.walk(source):
for filename in filenames:
if filename.endswith(('.mov', '.mkv', '.dv')):
if filename[0] != '.':
full_path = os.path.join(root, filename)
cmd = [
'ffmpeg',
'-i',
full_path,
'-f',
'framemd5',
'-an',
full_path + '_source.framemd5'
]
subprocess.call(cmd)
if __name__ == '__main__':
main()