There is a python module called pymediainfo - https://pypi.org/project/pymediainfo/
You can use this to get the required metadata of the media file.
Create a directory
mkdir supportfiles
For some reasons I install the module in target directory called "supportfiles"
pip install pymediainfo -t supportfiles/
To get the dimension/resolution of the video file
resolution.py
from supportfiles.pymediainfo import MediaInfo
media_info = MediaInfo.parse('/home/sathish/Videos/Aandipatti.mp4')
for track in media_info.tracks:
if track.track_type == 'Video':
print ("Resolution {}x{}".format(track.width, track.height))
Here is the output
[sathish@localhost test]$ python3.6 resolution.py
Resolution 1920x1080
Just in case if you want to know the list of metadata attributes, Here is the solution
attributes.py
from supportfiles.pymediainfo import MediaInfo
media_info = MediaInfo.parse('/home/sathish/Videos/Aandipatti.mp4')
print(media_info.tracks)
for track in media_info.tracks:
if track.track_type == 'Video':
print(track.to_data().keys())
elif track.track_type == 'Audio':
print(track.to_data().keys())
elif track.track_type == 'General':
print(track.to_data().keys())
else:
print("No metadata present! or probably file corrupt!")
Here is the list of the attributes
[sathish@localhost test]$ python3.6 attributes.py
[
Hope this will be useful!