Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bfaec2a

Browse files
committed
extract metadata
1 parent f1b3ac5 commit bfaec2a

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

ffprobe3/ffprobe.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,25 @@ def __init__(self, path_to_video):
5454
elif stream:
5555
data_lines.append(line)
5656

57+
self.metadata = {}
58+
is_metadata = False
59+
stream_metadata_met = False
60+
5761
for line in iter(p.stderr.readline, b''):
5862
line = line.decode('UTF-8')
5963

64+
if 'Metadata:' in line and not stream_metadata_met:
65+
is_metadata = True
66+
elif 'Stream #' in line:
67+
is_metadata = False
68+
stream_metadata_met = True
69+
elif is_metadata:
70+
splits = line.split(',')
71+
for s in splits:
72+
m = re.search(r'(\w+)\s*:\s*(.*)$', s)
73+
# print(m.groups())
74+
self.metadata[m.groups()[0]] = m.groups()[1].strip()
75+
6076
if '[STREAM]' in line:
6177
stream = True
6278
data_lines = []

0 commit comments

Comments
 (0)