I'm working on a site that users uploads videos and audio files, I when uploaded, some common metadata fields must be populated from the file. I have found Hachoir and it seems good, but with a problem, to create a parser for metadata reading, what is required is a filename, rather than a file-like or stream object.
How to use Hachoir with file like objects?
hachoir-metadata has three modes: classic mode: extract metadata, you can use –level=LEVEL to limit quantity of information to display (and not to extract) --type : show on one line the file format and most important informations. --mime : just display file MIME type.
ExifTool is a powerful tool used to extract metadata of a file. It is used not only on images but some other formats of files like PDF and mp4 etc. It enables us to update and remove metadata of files and gives a lot of information about files.
The proposed algorithmic metadata extraction model leverages the capacity of deep learning classification techniques to identify text lines in a given document that discusses metadata information of the proposed algorithmic PC within.
Using Hachoir v3.2.1:
import hachoir.metadata
import hachoir.parser
import hachoir.stream
parser = hachoir.parser.guessParser(hachoir.stream.InputIOStream(file_handle, None, tags=[]))
if parser:
hachoir_metadata = hachoir.metadata.extractMetadata(parser)
if hachoir_metadata:
metadata: Dict[str, str] = hachoir_metadata.exportDictionary()['Metadata']
print(metadata)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With