Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix system audio on macos

Brendan Allan3c4dd09cfd3c
diff --git a/Cargo.lock b/Cargo.lock
index 177138f4a..db9550ad1 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -6374,7 +6374,7 @@ dependencies = [
[[package]]
name = "scap"
version = "0.0.8"
-source = "git+https://github.com/CapSoftware/scap?rev=35ece62a0014#35ece62a0014ef74a4fa80ea4985e29e72fe1e9b"
+source = "git+https://github.com/CapSoftware/scap?rev=d99830264854#d998302648546946ad08b7d92b4e65648e2b4f6b"
dependencies = [
"cocoa 0.25.0",
"core-foundation 0.10.0",
diff --git a/Cargo.toml b/Cargo.toml
index ad9abc68a..6fd9761ac 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -25,7 +25,7 @@ specta = { version = "=2.0.0-rc.20", features = [
"uuid",
] }
-scap = { git = "https://github.com/CapSoftware/scap", rev = "35ece62a0014" }
+scap = { git = "https://github.com/CapSoftware/scap", rev = "d99830264854" }
nokhwa = { git = "https://github.com/CapSoftware/nokhwa", rev = "e309b938ccd6", features = [
"input-native",
"serialize",
diff --git a/crates/media/src/sources/audio_mixer.rs b/crates/media/src/sources/audio_mixer.rs
index bd9e75327..ac7e55fe2 100644
--- a/crates/media/src/sources/audio_mixer.rs
+++ b/crates/media/src/sources/audio_mixer.rs
@@ -2,7 +2,7 @@ use std::time::{Duration, SystemTime};
use ffmpeg_sys_next::AV_TIME_BASE_Q;
use flume::{Receiver, Sender};
-use tracing::warn;
+use tracing::{debug, warn};
use crate::{
data::{AudioInfo, FFAudio},
@@ -68,6 +68,8 @@ impl AudioMixer {
info.channel_layout().bits()
);
+ debug!("audio mixer input {i}: {args}");
+
filter_graph
.add(
&ffmpeg::filter::find("abuffer").expect("Failed to find abuffer filter"),
@@ -89,11 +91,14 @@ impl AudioMixer {
)
.unwrap();
+ let aformat_args = "sample_fmts=flt:sample_rates=48000:channel_layouts=stereo";
+ debug!("aformat args: {aformat_args}");
+
let mut aformat = filter_graph
.add(
&ffmpeg::filter::find("aformat").expect("Failed to find aformat filter"),
"aformat",
- "sample_fmts=flt:sample_rates=48000:channel_layouts=stereo",
+ aformat_args,
)
.expect("Failed to add aformat filter");
@@ -131,8 +136,9 @@ impl AudioMixer {
Err(flume::TryRecvError::Disconnected) => return,
Err(flume::TryRecvError::Empty) => break,
};
+ let frame = &value.0;
- abuffers[i].source().add(&value.0).unwrap();
+ abuffers[i].source().add(&frame).unwrap();
}
}
diff --git a/crates/recording/src/capture_pipeline.rs b/crates/recording/src/capture_pipeline.rs
index 6aefab518..8f7b1287c 100644
--- a/crates/recording/src/capture_pipeline.rs
+++ b/crates/recording/src/capture_pipeline.rs
@@ -217,7 +217,7 @@ impl MakeCapturePipeline for AVFrameCapture {
audio: Option<&AudioInputFeed>,
system_audio: Option<(Receiver<(ffmpeg::frame::Audio, f64)>, AudioInfo)>,
output_path: PathBuf,
- pause_flag: Arc<AtomicBool>,
+ _pause_flag: Arc<AtomicBool>,
) -> Result<CapturePipelineBuilder, MediaError>
where
Self: Sized,
@@ -266,11 +266,11 @@ impl MakeCapturePipeline for AVFrameCapture {
let _ = ready.send(Ok(()));
while let Ok((frame, unix_time)) = source.1.recv() {
if let Ok(mut mp4) = mp4.lock() {
- if pause_flag.load(std::sync::atomic::Ordering::Relaxed) {
- mp4.pause();
- } else {
- mp4.resume();
- }
+ // if pause_flag.load(std::sync::atomic::Ordering::Relaxed) {
+ // mp4.pause();
+ // } else {
+ // mp4.resume();
+ // }
mp4.queue_video_frame(frame);
}
@@ -289,10 +289,10 @@ type ScreenCaptureReturn<T> = (
Receiver<(<T as ScreenCaptureFormat>::VideoFormat, f64)>,
);
-// #[cfg(target_os = "macos")]
-// pub type ScreenCaptureMethod = CMSampleBufferCapture;
+#[cfg(target_os = "macos")]
+pub type ScreenCaptureMethod = CMSampleBufferCapture;
-// #[cfg(not(target_os = "macos"))]
+#[cfg(not(target_os = "macos"))]
pub type ScreenCaptureMethod = AVFrameCapture;
pub fn create_screen_capture(
diff --git a/crates/recording/src/instant_recording.rs b/crates/recording/src/instant_recording.rs
index b819a37bb..8b3046b7f 100644
--- a/crates/recording/src/instant_recording.rs
+++ b/crates/recording/src/instant_recording.rs
@@ -109,7 +109,7 @@ pub struct CompletedInstantRecording {
pub meta: InstantRecordingMeta,
}
-#[tracing::instrument(skip_all, name = "standalone")]
+#[tracing::instrument(skip_all, name = "instant")]
async fn create_pipeline<TCaptureFormat: MakeCapturePipeline>(
output_path: PathBuf,
screen_source: (