-
Notifications
You must be signed in to change notification settings - Fork 375
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
Add encode_lazy method to CodecContext #1092
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some codecs (VP9) can both buffer _many_ frames, and take a long time encoding each frame. Accumulated, the last `encode(None)`-flush can end taking a long time >30s, without detectable progress. FFmpeg and many encoders themselves output one frame at a time, but PyAV currently buffer them all up into lists returned. This change adds a `encode_lazy` yielding frames as they are made ready. The change was benchmarked to also yield a net performance improvement. For both `encode()` and `encode_lazy` encoding really small (24x18) frames using the `mpeg4` encoder seem to take ~11% less time.
rawler
force-pushed
the
generator-encode-decode
branch
from
February 25, 2023 23:24
7adfa9f
to
9f3b419
Compare
rawler
changed the title
[codec context] Let decode return a generator
[codec context] Add decode_lazy() returning a generator
Feb 25, 2023
I also attempted to make the same change to Benchmarked as
Encode() elapsed before:
Encode() elapsed after:
Encode_lazy() after:
|
WyattBlue
changed the title
[codec context] Add decode_lazy() returning a generator
Add encode_lazy method to CodecContext
Nov 25, 2023
WyattBlue
force-pushed
the
generator-encode-decode
branch
from
November 25, 2023 09:05
f706204
to
9f3b419
Compare
Thanks, merging. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Some codecs (libvpx-vp9) can both buffer many frames, and take a long time encoding each frame. Accumulated, the last
encode(None)
-flush can end up taking a long time >30s, without detectable progress.FFmpeg and many encoders themselves output one frame at a time, but PyAV currently buffer them all up into lists returned.
This change adds a
encode_lazy()
, yielding frames as they are made ready.The change was benchmarked to also yield a net performance improvement. For both
encode()
andencode_lazy
, encoding really small (24x18) frames using thempeg4
encoder seem to take ~11% less time.