898256d416
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.
25 lines
778 B
CMake
25 lines
778 B
CMake
project(obs-ffmpeg-mux)
|
|
|
|
option(ENABLE_FFMPEG_MUX_DEBUG "Enable FFmpeg-mux debugging" OFF)
|
|
|
|
find_package(FFmpeg REQUIRED COMPONENTS avcodec avutil avformat)
|
|
|
|
add_executable(obs-ffmpeg-mux)
|
|
add_executable(OBS::ffmpeg-mux ALIAS obs-ffmpeg-mux)
|
|
|
|
target_sources(obs-ffmpeg-mux PRIVATE ffmpeg-mux.c ffmpeg-mux.h)
|
|
|
|
target_link_libraries(obs-ffmpeg-mux PRIVATE OBS::libobs FFmpeg::avcodec
|
|
FFmpeg::avutil FFmpeg::avformat)
|
|
if(OS_WINDOWS)
|
|
target_link_libraries(obs-ffmpeg-mux PRIVATE OBS::w32-pthreads)
|
|
endif()
|
|
|
|
if(ENABLE_FFMPEG_MUX_DEBUG)
|
|
target_compile_definitions(obs-ffmpeg-mux PRIVATE ENABLE_FFMPEG_MUX_DEBUG)
|
|
endif()
|
|
|
|
set_target_properties(obs-ffmpeg-mux PROPERTIES FOLDER "plugins/obs-ffmpeg")
|
|
|
|
setup_binary_target(obs-ffmpeg-mux)
|