-
Notifications
You must be signed in to change notification settings - Fork 3
/
video_parse_test.py
52 lines (42 loc) · 1.36 KB
/
video_parse_test.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
from hachoir_parser import createParser
from hachoir_metadata import extractMetadata
from hachoir_core.cmd_line import unicodeFilename
import os
# Get the metadata from this filename
def getMetadata(filename):
filename, realname = unicodeFilename(filename), filename
parser = createParser(filename, realname)
if not parser:
print "Unable to parse file"
exit(1)
metadata = extractMetadata(parser)
return metadata
dirpath = '/Users/elliots/Movies/dance_tutorials/spain_videos_miguel/'
filename = '9-3-2015.mp4'
file_data = getMetadata(dirpath + filename)
print file_data
print file_data.get('duration')
#print vars(file_data)
#print file_data.get('camera_model')
full_filelist = []
for file in os.listdir(dirpath):
if os.path.isfile(dirpath + file):
file_data = getMetadata(dirpath + file)
len = file_data.get('duration')
date = file_data.get('creation_date')
print len
print date
full_filelist.append([date, len])
elif os.path.isdir(dirpath + file):
dirpath = dirpath + file + '/'
for file in os.listdir(dirpath):
file_data = getMetadata(dirpath + file)
len = file_data.get('duration')
date = file_data.get('creation_date')
print len
print date
full_filelist.append([date, len])
# Make sure we have valid data (e.g. the dates aren't just zero)
#print full_filelist
for file in sorted(full_filelist, key=lambda vid: vid[0]):
print file[0]