Allow the timestamp for a frame to be supplied to the MJPEGStream.#387
Open
julianstirling wants to merge 2 commits into
Open
Allow the timestamp for a frame to be supplied to the MJPEGStream.#387julianstirling wants to merge 2 commits into
julianstirling wants to merge 2 commits into
Conversation
Cameras can report their capture timestamp. This allows add_frame to accept the timestamp (and fallback to datetime.now()) if no timestamp is supplied. This allows for more accurate timestamps for the frame which is useful if the frametime needs to be known relative to anothe event.
bprobert97
reviewed
Jul 10, 2026
bprobert97
reviewed
Jul 10, 2026
bprobert97
approved these changes
Jul 10, 2026
julianstirling
commented
Jul 11, 2026
Co-authored-by: Beth <167304066+bprobert97@users.noreply.github.com> Co-authored-by: Julian Stirling <julian@julianstirling.co.uk>
Contributor
|
Want review from @rwb27 before merging |
rwb27
approved these changes
Jul 14, 2026
rwb27
left a comment
Collaborator
There was a problem hiding this comment.
This is great, and something I've intended to add since realising that the camera timestamp is passed through the pi camera's encoder.
| return MJPEGStreamResponse(self.frame_async_generator()) | ||
|
|
||
| def add_frame(self, frame: bytes) -> None: | ||
| def add_frame(self, frame: bytes, timestamp: Optional[datetime] = None) -> None: |
Collaborator
There was a problem hiding this comment.
I have favoured datetime | None but let's not worry about it until there's a linter rule to enforce consistency.
This file contains hidden or 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
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.
Cameras can report their capture timestamp. This allows add_frame to accept the timestamp (and fallback to datetime.now()) if no timestamp is supplied.
This allows for more accurate timestamps for the frame which is useful if the frametime needs to be known relative to anothe event.