forked from obsproject/obs-studio
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
obs-ffmpeg: Add a circlebuf to buffer output in ffmpeg-mux
This adds a circular buffer to ffmpeg-mux when writing to a file. Output from ffmpeg is buffered so that slow disk I/O does not block ffmpeg writes, as this causes the pipe to become full and OBS stops sending frames with a misleading "Encoding overloaded!" warning. The buffer may grow to 256 MB depending on the rate of data coming in and out, if the buffer is full OBS will start waiting in ffmpeg writes. A separate I/O thread is responsible for processing the contents of the buffer and writing them to the output file. It tries to process 1 MB at a time to minimize small I/O. Complicating things considerably, some formats in ffmpeg require seeking on the output, so we can't just treat everything as a stream of bytes. To handle this, we record offsets of each write and try to buffer as many contiguous writes as possible. This unfortunately makes the code quite complicated, but hopefully well commented.
- Loading branch information
Showing
2 changed files
with
295 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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