-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
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
Make stream recorder work concurrently #73478
Conversation
Hey there @hunterjm, @allenporter, mind taking a look at this pull request as it has been labeled with an integration ( |
77c996c
to
3f1d98e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a great improvement! Really like the idea of writing the stream as soon as possible rather than buffering the entire recording.
I have hust a couple questions about the core of the worker loop.
_LOGGER.error("Recording failed to capture anything") | ||
else: | ||
output.close() | ||
os.rename(self.video_path + ".tmp", self.video_path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I put this part in (writing to a file with a different name first) because I believe some users currently use the existence of the output file to check whether the recording is done yet.
Write lookback segments before main loop
4b6d663
to
775bfd4
Compare
Rebased on dev |
Set idle = True before firing event
Proposed change
The current stream recorder works by spawning a recorder worker thread from the RecorderOutput.cleanup() function once the intended duration is reached and the RecorderOutput is removed. Since the worker is not called until the end of the recording, the video data is retained in the RecorderOutput until this time, and the work to remux the video is done all at this time.
This PR changes the
async_record
call to use a newRecorderOutput.async_record
method which processes each segment in real time (farming the actual muxing work out with executor thread tasks). This may reduce the memory usage for longer recordings of several minutes or more, and it may also allow for recovery of a partial file in case there is an interruption to HA during the recording.Type of change
Additional information
Checklist
black --fast homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
..coveragerc
.The integration reached or maintains the following Integration Quality Scale:
To help with the load of incoming pull requests: