Expose CodecContext flush_buffers #1382
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
.