[Feature]: Add async or non-blocking video write support for GStreamer `VideoWriter`
#859 opened on Mar 27, 2026
Repository metrics
- Stars
- (675 stars)
- PR merge metrics
- (PR metrics pending)
Description
Explore write_async or another non-blocking write path for GStreamer video writing so frame submission does not unnecessarily block the caller during encode or mux backpressure.
Motivation
The current VideoWriter::write path is synchronous. In practice, video pipelines may slow down because of encoder work, muxing, sink pressure, or queued buffers. That can make the caller wait longer than expected, which is undesirable in async runtimes, live pipelines, and high-throughput frame producers.
Proposed Solution
- Review the current synchronous
writepath and identify where blocking may occur. - Design an async-friendly alternative such as:
write_async- a background worker / queued writer
- a documented
try_writeor non-blocking push strategy
- Preserve the current synchronous API unless maintainers want a broader redesign.
- Make backpressure behavior explicit in the API and documentation.
- Add an example or benchmark that compares sync and async/background behavior under load.
Expected Outcome
Users can integrate video writing into async or throughput-sensitive applications more safely, with a clearer understanding of blocking behavior and better runtime compatibility.
✅ Acceptance Criteria
- A clear API decision is made (
write_async, queued background writer, or equivalent). - Blocking behavior is documented explicitly.
- Existing synchronous behavior remains supported or is migrated cleanly.
- At least one example or test demonstrates recommended usage.
- Performance or responsiveness improvement is shown with a simple benchmark or measurement.
Additional Context
This issue is closely related to buffer-copy optimization, but it should still be tracked separately. Even if per-frame copies are reduced, the encode/mux path may still introduce backpressure. Any async design should also define flush, drop, and shutdown semantics clearly.
Code Reference
// crates/kornia-io/src/gstreamer/video.rs ~181
// TODO: explore supporting write_async
🤝 Contribution Intent
- I plan to submit a PR to implement this feature
- I'm requesting this feature but not planning to implement it