I am writing a Windows application in Python that should read metadata from a .MP4 video file .
I started writing an application in Python 3, but I could not find a suitable module for reading metadata from video files. This is when I used 3to2 to move the entire project to Python 2, so I could install Hachoir-Metadata , which was evaluated all over the network using pip install hachoir-core , pip install hachoir-parser and pip install hachoir-metadata
I used the following code:
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
This returned the following metadata:
- Duration: 37 seconds 940 ms
- Image Width: 1280 pixels
- Image height: 960 pixels
- Date Created: 2014-12-13 19:27:36
- Last modification: 2014-12-13 19:27:36
- Comment: Playback speed: 100.0%
- Comment: User volume: 100.0%
- MIME Type: Video / Fast Time
- Endianness: Big endian
This is great, except for the fact that I also really need to know frames per second (FPS). For .AVI files, Hachoir-Metadata shows FPS, as you can see from this test output:
- Duration: 6 sec. 66 ms
- Image Width: 256 pixels
- Image height: 240 pixels
- Frame Rate: 30.0 fps
- Bitrate: 884.4 Kbps
- Comment: has an audio / video index (2920 bytes)
- MIME Type: Video / x -msvideo
- Endianness: little endian
And yes, the FPS tag is set in the .MP4 file (100 frames per second).
Is there a way to extract FPS from a .MP4 file? It is preferable to include width (px), height (px), duration and creation time.
Thanks in advance for your help!
source share