A Python wrapper for Mediainfo
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
.mediainfo.tpl
.test_wrapmediainfo.py
.travis.yml
LICENSE
README.md
wrapmediainfo.py

README.md

wrapmediainfo

A very simple Python wrapper for Mediainfo

Build Status

It uses the Mediainfo's templating functionality to try to get the following information:

  • 'displayAspectRatio'
  • 'filesize'
  • 'audioBitrate'
  • 'videoBitrate'
  • 'videoFormatProfile'
  • 'audioLanguage'
  • 'subLanguage'
  • 'subCodec'
  • 'height'
  • 'width'
  • 'audioCodec'
  • 'videoCodec'
  • 'audioChannels'
  • 'audioFormat'
  • 'videoFormat'
  • 'duration'

Requirements:

Configuration:

If Mediainfo is intalled in a different path, edit wrapmediainfo.py and change

# Adjust to your system config
mediainfoBin = "/usr/bin/mediainfo"

How to use:

  • In a script: Call function "mediaMetadataExtract" with the filename as parameter. Metadata will be parsed and you will get a dictionary.
  • From command line:
$ python3 wrapmediainfo.py -f "Sample_Big_Buck_Bunny_Trailer_(HD)_(Source).flv"
  {'videoCodec': 'On2 VP6', 'videoFormatProfile': None, 'videoFormat': 'VP6', 'audioBitrate': '64000', 'filename': 'Sample_Big_Buck_Bunny_Trailer_(HD)_(Source).flv', 'displayAspectRatio': '16:9', 'duration': '33049', 'audioLanguage': None, 'audioChannels': '2', 'audioCodec': 'MPEG-1 Audio layer 3', 'videoBitrate': '2720694', 'filesize': '11582028', 'width': '1280', 'height': '720', 'status': 0}

Error handling:

  • Non media files will show an output similar to this and will not be considered failed (note 'status'):
{'filename': 'README.md', 'filesize': '1488', 'duration': None, 'status': 0}
  • Non existent files will show an output similat to this and will be considered failed (note 'status'):
{'filesize': 0, 'filename': 'i_dont_exist', 'status': 1}