void avcodec_flush_buffers ( AVCodecContext * avctx )
Reset the internal codec state / flush internal buffers.
Should be called e.g. when seeking or when switching to a different stream.
Currently with PyAV the only way to reset the CodecContext state is to call seek on the container. This has the downside that it resets the codecs for ALL the streams. This can be annoying if you are doing more advanced stuff like switching between streams midway but don't want to call seek, selectively decode only some streams based on logic, or have the decoding heads at different points in time for different streams and need to sync them up, etc. Exposing avcodec_flush_buffers makes it much easier to decode in whatever order you want or even in different orders in different streams.
I also added type hints for encode and decode since those are missing from codec/context.pyi.
expose
avcodec_flush_buffers()
From ffmpeg documentation (https://ffmpeg.org/doxygen/trunk/group__lavc__misc.html#gaf60b0e076f822abcb2700eb601d352a6)
Currently with PyAV the only way to reset the CodecContext state is to call seek on the container. This has the downside that it resets the codecs for ALL the streams. This can be annoying if you are doing more advanced stuff like switching between streams midway but don't want to call seek, selectively decode only some streams based on logic, or have the decoding heads at different points in time for different streams and need to sync them up, etc. Exposing
avcodec_flush_buffers
makes it much easier to decode in whatever order you want or even in different orders in different streams.I also added type hints for
encode
anddecode
since those are missing fromcodec/context.pyi
.