Skip to content

v10 no longer writes "rotate" metadata flag #1045

@FirefoxMetzger

Description

@FirefoxMetzger

Overview

As of v10.0.0 the stream metadata flag rotate is no longer written to file. This may affect other metadata fields; however, for this one specifically, we have a unit-test downstream so I know for sure that it is affected.

Expected behavior

Setting a field in a video stream's metadata dict causes it to be written to the file.

Actual behavior

Stream-level metadata (at least the rotation flag) is no longer written.

Reproduction

import av
import numpy as np

print(f"PyAV version: {av.__version__}")

with av.open("test.mp4", "w") as container:
    container.metadata["comment"] = "This video has a rotation flag."

    stream = container.add_stream("libx264", 24)
    stream.metadata["rotate"] = "90"

    for _ in range(24):
        frame = av.VideoFrame.from_ndarray(np.ones((128, 128, 3), dtype=np.uint8))
        for packet in stream.encode(frame):
            container.mux(packet)

    for packet in stream.encode():
        container.mux(packet)

with av.open("test.mp4") as container:
    print(container.metadata)
    video_stream = container.streams.video[0]
    print(video_stream.metadata)

Using av v9.2 the above snippet produces:

PyAV version: 9.2.0
{'major_brand': 'isom', 'minor_version': '512', 'compatible_brands': 'isomiso2avc1mp41', 'encoder': 'Lavf58.76.100', 'comment': 'This video has a rotation flag.'}
{'rotate': '90', 'language': 'und', 'handler_name': 'VideoHandler', 'vendor_id': '[0][0][0][0]'}

However, when switching to v10 it produces:

PyAV version: 10.0.0
{'major_brand': 'isom', 'minor_version': '512', 'compatible_brands': 'isomiso2avc1mp41', 'encoder': 'Lavf59.27.100', 'comment': 'This video has a rotation flag.'}
{'language': 'und', 'handler_name': 'VideoHandler', 'vendor_id': '[0][0][0][0]'}

Versions

  • OS: Windows 11 and Ubuntu 20.04
  • PyAV runtime:
PyAV v10.0.0
library configuration: --disable-static --enable-shared --libdir=/c/cibw/vendor/lib --prefix=/c/cibw/vendor --disable-alsa --disable-doc --disable-mediafoundation --enable-fontconfig --enable-gmp --disable-gnutls --enable-gpl --enable-libaom --enable-libass --enable-libbluray --enable-libdav1d --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --disable-libxcb --enable-libxml2 --enable-libxvid --enable-lzma --enable-version3 --enable-zlib
library license: GPL version 3 or later
libavcodec     59. 37.100
libavdevice    59.  7.100
libavfilter     8. 44.100
libavformat    59. 27.100
libavutil      57. 28.100
libswresample   4.  7.100
libswscale      6.  7.100
  • FFmpeg: (pypi shipped binary)

Research

I have done the following:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions