• Looking for package/library to extract MP4 metadata

    From Chris Green@21:1/5 to All on Sun Apr 9 09:40:51 2023
    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.

    --
    Chris Green
    ·

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From rbowman@21:1/5 to Chris Green on Sun Apr 9 16:31:46 2023
    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/

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris Green@21:1/5 to rbowman on Sun Apr 9 18:05:56 2023
    rbowman <bowman@montana.com> wrote:
    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/

    Oh, OK, thanks. I already have mutagen installed on my systems
    because I use QuodLibet. I hadn't realised it would let me look at
    MP4 video files but I guess it should.

    --
    Chris Green
    ·

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From jak@21:1/5 to All on Sun Apr 9 20:23:52 2023
    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris Green@21:1/5 to jak on Sun Apr 9 20:19:37 2023
    jak <nospam@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.

    --
    Chris Green
    ·

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From rbowman@21:1/5 to Chris Green on Mon Apr 10 03:01:00 2023
    On Sun, 9 Apr 2023 20:19:37 +0100, Chris Green wrote:

    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.

    If yuo chase back through the various ISOs you tend to wind up at Apple's QuickTime container format as the parent. The compression methods for the
    media etc will differ but at least the structure of the file is
    documented. It's tedious but you can walk through the atoms (chunks,
    blocks, boxes) and find the metadata.

    There is the disclaimer

    https://mutagen.readthedocs.io/en/latest/user/mp4.html

    so it may not work for your intended purposes, particularly for modifying
    the data. That gets tricky since it may change the size of the chunk.

    https://pypi.org/project/tinytag/

    is another one but it's only for reading the metadata.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From jak@21:1/5 to All on Mon Apr 10 12:59:00 2023
    Chris Green ha scritto:
    jak <nospam@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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris Green@21:1/5 to jak on Mon Apr 10 13:10:05 2023
    jak <nospam@please.ty> wrote:
    Chris Green ha scritto:
    jak <nospam@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.

    Thank you, that worked straight away, ffprobe is installed on my
    systems already and I can probably just grep for the tag I want as all
    I'm looking for is the date of its creation which appears (twice) with
    the tag "creation_time".

    This is just to handle the occasional MP4 that a python program which
    basically manages JPEGs can't handle. It throws an exception so I can
    just get that to run a simple bash script to get the creation date.

    --
    Chris Green
    ·

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Cameron Simpson@21:1/5 to Chris Green on Tue Apr 11 10:27:35 2023
    On 10Apr2023 13:10, Chris Green <cl@isbd.net> wrote:
    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.

    Thank you, that worked straight away, ffprobe is installed on my
    systems already and I can probably just grep for the tag I want as all
    I'm looking for is the date of its creation which appears (twice) with
    the tag "creation_time".

    This is just to handle the occasional MP4 that a python program which >basically manages JPEGs can't handle. It throws an exception so I can
    just get that to run a simple bash script to get the creation date.

    Yes, ffprobe is great, particularly the JSON output mode, very parsable.

    If you want to get into the knitty gritty you could try my `cs.iso14496` package, which has a full MP4/MOV parser and a hook for getting the
    metadata.

    Not as convenient as ffprobe, but if you care about the innards...

    Cheers,
    Cameron Simpson <cs@cskk.id.au>

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)