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.
I've been working on some code that captures audio and attempts to precisely synchronize it with PiCamera video. I've been having a lot of trouble getting precise control over the number of seconds written by PiCameraCircularIO.copy_to(). This PR attempts to address this issue, and also adds some minor features I've found useful.
The problem is in the handling of frames that are split into multiple chunks (where only the last chunk is marked 'complete'). When chunks are delivered to PiVideoEncoder._callback_write(), only the first chunk of a frame gets a timestamp (I believe this is a hardware behavior). However, in PiCameraDequeueHack.append(), frame metadata is only saved for the last chunk of a frame. The net result is that split frames never have timestamp data visible to PiCameraCircularIO._find_seconds(), causing it to skip over them.
This PR makes the following changes: