Looking for package/library to extract MP4 metadata

jak nospam at please.ty
Mon Apr 10 06:59:00 EDT 2023


Chris Green ha scritto:
> jak <nospam at please.ty> wrote:
>> rbowman ha scritto:
>>> On Sun, 9 Apr 2023 09:40:51 +0100, Chris Green wrote:
>>>
>>>> I'm looking for a Python (3) library to access (read only at present)
>>>> the metadata in MP4 video files, in particular I want to get at dates
>>>> and times.
>>>>
>>>> What's available to do this?  Ideally something available in the Ubuntu
>>>> repositories but I can install with PIP if necessary.
>>>
>>> https://mutagen.readthedocs.io/en/latest/
>>>
>>
>> I thought it only dealt about audio.
> 
> That's why I hadn't thought it would help me as I'm after getting
> metadata from an MP4 video file but I guess the metadata format may be
> the same regardless of whether it's video or audio.
> 

Easiest way I found was run ffprobe command via popen. It can output the
information you need in json format which is easily readable with the
json library.

command:
ffprobe -v warning -i "input.mp4" -show_streams -of json
python:
Popen(command, stderr=STDOUT, stdout=PIPE, encoding='utf8')
json:
json.loads(''.join(p.stdout.readlines()))

It's easy to find a version of ffmpeg/ffprobe for every platform.


More information about the Python-list mailing list