Skip to content

Commit ea5570f

Browse files
committed
Add utility methods to the library
1 parent dce782b commit ea5570f

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

parse_test.py renamed to gpmf/extract.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#!/usr/bin/env python3
2-
import hachoir.metadata
32
import hachoir.parser
43

5-
64
from hachoir.field import MissingField
75
from hachoir.field.string_field import String
86

@@ -16,6 +14,17 @@ def get_raw_content(met):
1614
return stream.read(met.absolute_address, met.size)
1715

1816

17+
def get_gpmf_payloads_from_file(filepath):
18+
"""Get payloads from file, returns a tuple with the payloads iterator and the parser instance"""
19+
parser = hachoir.parser.createParser(filepath)
20+
return (get_payloads(find_gpmd_stbl_atom(parser)), parser)
21+
22+
23+
def get_gpmf_payloads(parser):
24+
"""Shorthand for finding the GPMF atom to be passed to get_payloads"""
25+
return get_payloads(find_gpmd_stbl_atom(parser))
26+
27+
1928
def get_payloads(stbl):
2029
"""Get payloads by chunk from stbl, with timing info"""
2130
# Locate needed subatoms

0 commit comments

Comments
 (0)