Skip to content

Instantly share code, notes, and snippets.

@dnicolson
Created November 1, 2015 21:25
Show Gist options
  • Save dnicolson/ea1d8b7614a588d98d97 to your computer and use it in GitHub Desktop.
Save dnicolson/ea1d8b7614a588d98d97 to your computer and use it in GitHub Desktop.
Extract mdat atoms from QuickTime files
from hachoir_core.cmd_line import unicodeFilename
from hachoir_parser import createParser
import sys
def find_atoms(filename):
parser = createParser(unicodeFilename(filename))
atoms = []
for field in parser:
print '%s: %s %s + %s' % (field.description, field.name, field.absolute_address, field.size)
if 'mdat' in field.description:
atoms.append({'addr': field.absolute_address / 8,
'size': field.size / 8})
return atoms
def extract(src, dst, start, size):
f = open(src)
f.seek(start)
open(dst, 'w').write(f.read(size))
info = find_atoms(sys.argv[1])
print info
extract(sys.argv[1], sys.argv[2], info[0]['addr'], info[0]['size'])
@eckirchn
Copy link

I am testing this on a FalconZero F170HD Dashcam. Ultimately, my goal is to extract out the realtime GPS data. I installed "hachoir_core" and "hachoir_parse" (note, a comment that those were required might be nice). I first tried the script as written, but ulitmately, was going to change this to look at the "ftyp" and "frea" atoms, as I think that might have the data I want.

python qt-extract.py 2016_0829_160810_056.MOV

Atom: ftyp: atom[0] 0 + 192
Atom: frea: atom[1] 192 + 1102368
Atom: mdat: atom[2] 1102560 + 3929484640
Atom: moov: atom[3] 3930587200 + 644808
[{'addr': 137820L, 'size': 491185580L}]
Traceback (most recent call last):
  File "qt-extract.py", line 22, in <module>
    extract(sys.argv[1], sys.argv[2], info[0]['addr'], info[0]['size'])
IndexError: list index out of range

Any suggestions? I tried AtomicParsley but that's only mp4, not quicktime containers.

@discarn8
Copy link

Eric - did you ever get anywhere with your pursuit to extract the GPS data from the FalconZero F170 mov files?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment