Skip to content

Conversation

@nowrep
Copy link
Contributor

@nowrep nowrep commented Aug 9, 2023

Start with 2 buffers and increase it when encoding starts to fall behind capture.

@nowrep nowrep changed the title Increase number of used buffers dynamically Dynamically increase number of used buffers Aug 9, 2023
@nowrep
Copy link
Contributor Author

nowrep commented Aug 9, 2023

The major source of encode thread lag behind capture thread is the encoder initialization that happens after capturing first frame. We could discard first captured frame and wait for encoder to initialize to reduce the number of used buffers even further.

On my system with this change:

libx264 = needs around 5-7 buffers
vaapi   = needs 3-4 buffers

@ammen99
Copy link
Owner

ammen99 commented Aug 9, 2023

At this point, seems to me we should separate buffer management into a separate data structure (preferably also a different file) to keep the code readable.

Copy link
Owner

@ammen99 ammen99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM now, thanks!

@ammen99 ammen99 merged commit 8792d4f into ammen99:master Aug 23, 2023
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