Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose CodecContext flush_buffers #1382

Merged
merged 1 commit into from
Apr 25, 2024
Merged

Expose CodecContext flush_buffers #1382

merged 1 commit into from
Apr 25, 2024

Conversation

skeskinen
Copy link
Contributor

expose avcodec_flush_buffers()

From ffmpeg documentation (https://ffmpeg.org/doxygen/trunk/group__lavc__misc.html#gaf60b0e076f822abcb2700eb601d352a6)

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.

@WyattBlue WyattBlue merged commit 7f357af into PyAV-Org:main Apr 25, 2024
12 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants