Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save documentprocessing/b3bd9e7708f0322defeefc17474dfdbc to your computer and use it in GitHub Desktop.
Save documentprocessing/b3bd9e7708f0322defeefc17474dfdbc to your computer and use it in GitHub Desktop.
Read Metadata information using hachoir-metadata API for Python
from hachoir.parser import createParser
from hachoir.metadata import extractMetadata
# File to extract metadata from
file_path = "media_file.mp4"
# Create a parser for the file
parser = createParser(file_path)
if not parser:
print("Unable to parse file.")
else:
# Extract metadata
metadata = extractMetadata(parser)
if metadata:
for line in metadata.exportPlaintext():
print(line)
else:
print("No metadata found.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment