Skip to content

Setting time_base when adding a stream to an output container #1524

@daveisfera

Description

@daveisfera

Overview

Accessing time_base now raises an error with 13.0 when specifying time_base when calling add_stream on an output container

Expected behavior

Able to specify the time_base on a stream like previous versions

Actual behavior

RuntimeError raised when it's called

Traceback:

Traceback (most recent call last):
  File \"/usr/src/app/test.py\", line 129, in test
    main()
  File \"/usr/src/app/test.py\", line 81, in _test
    stream = container.add_stream(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File \"av/container/output.pyx\", line 132, in av.container.output.OutputContainer.add_stream
  File \"av/stream.pyx\", line 111, in av.stream.Stream.__setattr__
  File \"av/codec/context.pyx\", line 511, in av.codec.context.CodecContext.time_base.__set__
RuntimeError: Cannot access 'time_base' as a decoder"

Investigation

Caused by this commit

Reproduction

Call add_stream with time_base, like this:

container.add_stream("h264", time_base=Fraction(1, 1000))

Versions

  • OS: Debian Bookworm
  • PyAV runtime: 13.0
PyAV v13.0.0
library configuration: --prefix=/usr --enable-shared --disable-static --disable-debug --disable-doc --disable-ffplay --enable-gpl --enable-libfdk_aac --enable-libx264 --enable-libx265 --enable-librsvg --enable-openssl --enable-nonfree --enable-libaom --extra-libs=-lpthread
library license: nonfree and unredistributable
libavcodec     60. 31.102
libavdevice    60.  3.100
libavfilter     9. 12.100
libavformat    60. 16.100
libavutil      58. 29.100
libswresample   4. 12.100
libswscale      7.  5.100
  • PyAV build:
pip3 install av==13.0.0 --no-binary av

Research

I have done the following:

Additional context

If there's another way to specify this, then I'm definitely up for switching how I specify this, but I believe this is a valid use case since it's an encoder rather than a decoder and maybe the issue is that something is wrong with the is_decoder check?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions