Skip to content

Honour timeout when muxing and closing an output container - #1

Closed
adrianrfreedman wants to merge 3 commits into
fix/output-blocking-networkfrom
fix/output-timeout-mux-close
Closed

adrianrfreedman wants to merge 3 commits into
fix/output-blocking-networkfrom
fix/output-timeout-mux-close

Conversation

@adrianrfreedman

Copy link
Copy Markdown
Owner

Stacked view of PyAV-Org#2414, scoped to just the new commits. The upstream PR is PyAV-Org#2414; this one exists only so the diff excludes PyAV-Org#2412.

av_hwframe_transfer_data() is a full GPU<->host frame copy that ran on
every hwaccel decoded/encoded frame while holding the GIL. Wrap call
sites, folding av_hwframe_get_buffer() into the upload's region since
it blocks when the surface pool is exhausted.
@adrianrfreedman
adrianrfreedman force-pushed the fix/output-timeout-mux-close branch from 32f1296 to e509ffd Compare September 23, 2026 14:38
adrianrfreedman and others added 2 commits September 23, 2026 10:54
Only opening armed the interrupt callback, so a peer that accepted the
connection and then stopped reading left av_interleaved_write_frame() and
av_write_trailer() blocked forever. Arm the read timeout around both.

Each mux gets the full timeout, as each demux already does. A close shares
one deadline across writing the trailer and flushing, so it cannot outlast
the timeout it was given.

The close side has no test of its own. A timed-out write leaves its error
on the AVIO context, so the trailer then fails at once rather than
blocking, and I could not get a peer to stall only between the last mux and
the close: loopback buffers are far larger than the 32KB AVIO buffer, and
AF_UNIX ones are small enough that the header blocks first.
@adrianrfreedman
adrianrfreedman force-pushed the fix/output-timeout-mux-close branch from e509ffd to 7a7d4a9 Compare September 23, 2026 14:58
@adrianrfreedman

Copy link
Copy Markdown
Owner Author

PyAV-Org#2412 has merged, so 2414 is a single commit against main now. This view is no longer needed.

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.

3 participants