@@ -68,7 +68,8 @@ impl ScreenCaptureConfig<CMSampleBufferCapture> {
6868 & self ,
6969 ) -> anyhow:: Result < ( VideoSourceConfig , Option < SystemAudioSourceConfig > ) > {
7070 let ( error_tx, error_rx) = broadcast:: channel ( 1 ) ;
71- let ( video_tx, video_rx) = flume:: bounded ( 4 ) ;
71+ // Increased from 4 to 12 to provide more buffer tolerance for frame processing delays
72+ let ( video_tx, video_rx) = flume:: bounded ( 12 ) ;
7273 let ( mut audio_tx, audio_rx) = if self . system_audio {
7374 let ( tx, rx) = mpsc:: channel ( 32 ) ;
7475 ( Some ( tx) , Some ( rx) )
@@ -128,12 +129,16 @@ impl ScreenCaptureConfig<CMSampleBufferCapture> {
128129
129130 debug ! ( "size: {:?}" , size) ;
130131
132+ let queue_depth = ( ( self . config . fps as f32 / 30.0 * 5.0 ) . ceil ( ) as isize ) . clamp ( 3 , 8 ) ;
133+ debug ! ( "Using queue depth: {}" , queue_depth) ;
134+
131135 let mut settings = scap_screencapturekit:: StreamCfgBuilder :: default ( )
132136 . with_width ( size. width ( ) as usize )
133137 . with_height ( size. height ( ) as usize )
134138 . with_fps ( self . config . fps as f32 )
135139 . with_shows_cursor ( self . config . show_cursor )
136140 . with_captures_audio ( self . system_audio )
141+ . with_queue_depth ( queue_depth)
137142 . build ( ) ;
138143
139144 settings. set_pixel_format ( cv:: PixelFormat :: _32_BGRA) ;
0 commit comments