The Project: Add a running date/time stamp on each and every frame of a video. (The result of digital video camera, and my father asked me how can he add the timestamp(to the mi
Used hachoir-metadata to read metadata of video file(including Framerate, height and width .
importing:
from hachoir_core.error import HachoirError
from hachoir_core.cmd_line import unicodeFilename
from hachoir_parser import createParser
from hachoir_core.tools import makePrintable
from hachoir_metadata import extractMetadata
from hachoir_core.i18n import getTerminalCharset
from hachoir_metadata.metadata_item import QUALITY_BEST
function:
def metaDataFile(filePath):
filename, realname = unicodeFilename(filePath), filePath
parser = createParser(filename, realname)
try:
metadata = extractMetadata(parser, QUALITY_BEST)
except HachoirError, err:
print "Metadata extraction error: %s" % unicode(err)
metadata = None
if not metadata:
print metadata
print "Unable to extract metadata"
exit(1)
return metadata
usage:
metadata = metaDataFile(videoPath)
width = metadata.get('width')
height = metadata.get('height')
fps = metadata.get('frame_rate')
to see relevant properties:
for data in sorted(metadata):
if len(data.values ) > 0:
print data.key, data.values[0].value