Skip to content

Reading tags? #776

Closed
Closed

Description

@daveisfera

reader.get_meta_data() returns information about the video, but is there a way to get the metadata/tags from the video?

(I'm specifically interested in the tags from MKV files, but I assume this should be true for other video types as well)

Activity

  1. FirefoxMetzger commented on Apr 3, 2022

    @FirefoxMetzger
    Contributor

    That's a good question @daveisfera ; I'm not 100% sure, but I don't think the tags you linked are readable as of right now.

    I looked through the page you shared and the example files. I could have misunderstood, but it looks like those tag files are separate (XML) files that could/should be served in parallel to the actual video file. If that is the case, how would you expect this to be served when using ImageIO's API?

  2. daveisfera commented on Apr 3, 2022

    @daveisfera
    Author

    Sorry for the confusion there. My understanding is that the XML linked to on that page is just examples of the type of content that's possible and the actual data is in the file itself. I've attached an example here (note, I made the extension .mp4 just to make GitHub allow the upload of the file):
    https://user-images.githubusercontent.com/1686193/161445903-6d048ea2-662e-4e30-8303-4e30ee31cefd.mp4

    If you run ffprobe, then the output is:

    Input #0, matroska,webm, from '/Users/dlj/Downloads/example.mp4':
      Metadata:
        title           : Kinesis Video SDK
        encoder         : Kinesis Video SDK 1.1.0
        AWS_KINESISVIDEO_FRAGMENT_NUMBER: 91343852333194782758965329542477286734616584985
        AWS_KINESISVIDEO_SERVER_TIMESTAMP: 1649015662.391
        AWS_KINESISVIDEO_PRODUCER_TIMESTAMP: 1649015658.000
      Duration: N/A, start: 168.300000, bitrate: N/A
      Stream #0:0(eng): Video: hevc (Main), yuv420p(tv), 1280x720, SAR 1:1 DAR 16:9, 30.30 fps, 30.30 tbr, 1k tbn, 30 tbc (default)
        Metadata:
          title           : kvs_video_track
    

    And I'm interested in the tags listed under Metadata. Currently, I'm parsing them out separately, but it would be great, if I could get them as part of the parsing that I'm doing with imageio to avoid the two passes to get that data.

  3. FirefoxMetzger commented on Apr 4, 2022

    @FirefoxMetzger
    Contributor

    Ah, yeah it seems much more useful if the XML would be part of the file.

    In this case, it might be that the new pyAV wrapper that I've been writing is capable of reading those tags; however, I can't test this because Chrome won't allow me to download the video file you shared :(

  4. FirefoxMetzger commented on Apr 5, 2022

    @FirefoxMetzger
    Contributor

    Thanks for that @daveisfera .

    This is the metadata that pyAV reads at the moment:

    >>> import imageio.v3 as iio
    >>> # global/container metadata
    >>> iio.immeta("example.mkv", plugin="pyav", index=None) 
    {'video_format': 'yuv420p', 'codec': 'hevc', 'long_codec': 'HEVC (High Efficiency Video Coding)', 'profile': 'Main', 'title': 'kvs_video_track', 'encoder': 'Kinesis Video SDK 1.1.0', 'AWS_KINESISVIDEO_FRAGMENT_NUMBER': '91343852333194782758965329542477286734616584985', 'AWS_KINESISVIDEO_SERVER_TIMESTAMP': '1649015662.391', 'AWS_KINESISVIDEO_PRODUCER_TIMESTAMP': '1649015658.000', 'language': 'eng'}
    >>> # frame-specific metadata (side data)
    >>> iio.immeta("example.mkv", plugin="pyav", index=1)    
    {'title': 'Kinesis Video SDK', 'encoder': 'Kinesis Video SDK 1.1.0', 'AWS_KINESISVIDEO_FRAGMENT_NUMBER': '91343852333194782758965329542477286734616584985', 'AWS_KINESISVIDEO_SERVER_TIMESTAMP': '1649015662.391', 'AWS_KINESISVIDEO_PRODUCER_TIMESTAMP': '1649015658.000'}

    There is one metadata tag (the one under "stream #0") that is currently not being read. I'm not sure where it is stored, but it likely means that I forgot to add a location to the metadata. Edit: nvm, I just realized that the field I thought missing is part of the container-level metadata.

    Either way, would this solve the problem?

    For comparison, this is the metadata that is currently extracted by our FFMPEG plugin:

    >>> iio.immeta("example.mkv", plugin="FFMPEG", exclude_applied=False)
    {'plugin': 'ffmpeg', 'nframes': inf, 'ffmpeg_version': '4.2.2 built with gcc 9.2.1 (GCC) 20200122', 'codec': 'hevc', 'pix_fmt': 'yuv420p(tv)', 'fps': 30.3, 'source_size': (1280, 720), 'size': (1280, 720), 'duration': 0}

    Note that some of the fields that are present in FFMPEG are not present in pyAV. Some of them have been standardized across plugins and now live under properties:

    >>> foo = iio.improps("example.mkv", plugin="pyav")             
    >>> foo.shape  # "size" of the resulting numpy array
    (720, 1280, 3)
    >>> foo.dtype  # resulting dtype
    dtype('uint8')
  5. daveisfera commented on Apr 5, 2022

    @daveisfera
    Author

    Yes, that would be great!

  6. linked a pull request that will close this issueFEAT: New Plugin for pyAV #745on Apr 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions