Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

wip: Change format to YCbCr420Video

Richie McIlroy77353af41fcb
diff --git a/apps/desktop/src-tauri/src/capture/src/common/quartz.rs b/apps/desktop/src-tauri/src/capture/src/common/quartz.rs
index 1b20c1a23..47439447d 100644
--- a/apps/desktop/src-tauri/src/capture/src/common/quartz.rs
+++ b/apps/desktop/src-tauri/src/capture/src/common/quartz.rs
@@ -17,7 +17,7 @@ impl Capturer {
display.0,
width,
height,
- quartz::PixelFormat::Argb8888,
+ quartz::PixelFormat::YCbCr420Video,
Default::default(),
move |inner| {
if let Ok(mut f) = f.lock() {
@@ -38,26 +38,13 @@ impl Capturer {
}
pub fn frame(&mut self) -> io::Result<Frame> {
- match self.frame.try_lock() {
- Ok(mut handle) => {
- let mut frame = None;
- mem::swap(&mut frame, &mut handle);
-
- match frame {
- Some(frame) =>
- Ok(Frame(frame, PhantomData)),
-
- None =>
- Err(io::ErrorKind::WouldBlock.into())
- }
- }
-
- Err(TryLockError::WouldBlock) =>
- Err(io::ErrorKind::WouldBlock.into()),
-
- Err(TryLockError::Poisoned(..)) =>
- Err(io::ErrorKind::Other.into())
- }
+ let mut handle = self.frame.try_lock().map_err(|e| match e {
+ TryLockError::WouldBlock => io::ErrorKind::WouldBlock,
+ TryLockError::Poisoned(_) => io::ErrorKind::Other,
+ })?;
+
+ handle.take().map(|frame| Frame(frame, PhantomData))
+ .ok_or_else(|| io::ErrorKind::WouldBlock.into())
}
}
diff --git a/apps/desktop/src-tauri/src/capture/src/quartz/config.rs b/apps/desktop/src-tauri/src/capture/src/quartz/config.rs
index 843a8e835..517aea2f8 100644
--- a/apps/desktop/src-tauri/src/capture/src/quartz/config.rs
+++ b/apps/desktop/src-tauri/src/capture/src/quartz/config.rs
@@ -67,7 +67,7 @@ impl Default for Config {
cursor: true,
letterbox: true,
throttle: 0.001,
- queue_length: 1
+ queue_length: 3
}
}
}
diff --git a/apps/desktop/src-tauri/src/media.rs b/apps/desktop/src-tauri/src/media.rs
index b30efaf85..17cf0626a 100644
--- a/apps/desktop/src-tauri/src/media.rs
+++ b/apps/desktop/src-tauri/src/media.rs
@@ -66,8 +66,8 @@ impl MediaRecorder {
let mut w = max_screen_width;
let mut h = max_screen_height;
- let adjusted_width = w & !3;
- let adjusted_height = h & !3;
+ let adjusted_width = w & !1;
+ let adjusted_height = h & !1;
let capture_size = adjusted_width * adjusted_height * 4;
let (audio_tx, audio_rx) = tokio::sync::mpsc::channel::<Vec<u8>>(2048);
let (video_tx, video_rx) = tokio::sync::mpsc::channel::<Vec<u8>>(2048);
@@ -438,7 +438,7 @@ impl MediaRecorder {
let mut ffmpeg_video_command: Vec<String> = vec![
"-f", "rawvideo",
- "-pix_fmt", "bgra",
+ "-pix_fmt", "nv12",
"-s", &format!("{}x{}", w, adjusted_height),
"-r", "30",
"-thread_queue_size", "4096",