Skip to content

Wrong dtype for codec_context.flags #1718

@FirefoxMetzger

Description

@FirefoxMetzger

I just noticed that both flag fields (flags, flags2) in the codec context are type long in C but they should be unsigned long. The current setup leads to some strange errors when naively setting, for example, the CLOSED_GOP flag ... could we change this?

...
stream = container.add_stream("h264", 60)
stream.flags |= 0x80000000  # set cgop flag

results in

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "av\\codec\\context.pyx", line 119, in av.codec.context.CodecContext.flags.__set__
OverflowError: Python int too large to convert to C long

The current way to set this flag (in v14.0.1) is to use the corresponding signed representation of the flag. This is slightly unintuitive and not very self-explanatory:

stream = container.add_stream("h264", 60)
stream.flags |= -2147483648  # set cgop flag

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