Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 85 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[workspace]
resolver = "2"
members = ["apps/cli", "apps/desktop/src-tauri", "crates/*"]
members = ["apps/cli", "apps/desktop/src-tauri", "apps/multi-recorder", "crates/*"]

[workspace.dependencies]
anyhow = { version = "1.0.86" }
Expand Down Expand Up @@ -40,9 +40,10 @@ sentry = { version = "0.42.0", features = [
"debug-images",
] }
tracing = "0.1.41"
futures = "0.3.31"

cidre = { git = "https://github.com/CapSoftware/cidre", rev = "bf84b67079a8", features = [
futures = "0.3.31"
kameo = "0.17.2"

cidre = { git = "https://github.com/CapSoftware/cidre", rev = "bf84b67079a8", features = [
"macos_13_0",
"cv",
"cf",
Expand Down
20 changes: 10 additions & 10 deletions apps/desktop/src-tauri/src/captions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,27 +270,27 @@ async fn extract_audio_from_video(video_path: &str, output_path: &PathBuf) -> Re
}
}
Err(e) => {
log::error!("Failed to resample chunk {chunk_idx}: {e}");
log::error!("Failed to resample chunk {chunk_idx}: {:#}", e);
continue;
}
}

if let Err(e) = encoder.send_frame(&output_frame) {
log::error!("Failed to send frame to encoder: {e}");
log::error!("Failed to send frame to encoder: {:#}", e);
continue;
}

// Process each encoded packet
loop {
let mut packet = ffmpeg::Packet::empty();
match encoder.receive_packet(&mut packet) {
Ok(_) => {
if let Err(e) = packet.write_interleaved(&mut output) {
log::error!("Failed to write packet: {e}");
}
}
Err(_) => break,
}
match encoder.receive_packet(&mut packet) {
Ok(_) => {
if let Err(e) = packet.write_interleaved(&mut output) {
log::error!("Failed to write packet: {:#}", e);
}
}
Err(_) => break,
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions apps/desktop/src-tauri/src/frame_ws.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ pub async fn create_frame_ws(frame_rx: Receiver<WSFrame>) -> (u16, CancellationT
frame.data.extend_from_slice(&frame.width.to_le_bytes());

if let Err(e) = socket.send(Message::Binary(frame.data)).await {
tracing::error!("Failed to send frame to socket: {:?}", e);
tracing::error!("Failed to send frame to socket: {:#}", e);
break;
}
}
Err(e) => {
tracing::error!(
"Connection has been lost! Shutting down websocket server: {:?}",
"Connection has been lost! Shutting down websocket server: {:#}",
e
);
break;
Expand Down
93 changes: 93 additions & 0 deletions apps/multi-recorder/.planning-summary.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Planning Summary

This directory contains comprehensive planning documentation for the multi-recorder CLI tool.

## What We've Planned

A flexible CLI tool that allows users to:
1. Capture multiple input sources (displays, cameras, microphones)
2. Route them to multiple output files simultaneously
3. Configure sources with varying levels of detail
4. Support both simple CLI usage and complex config files

## Key Innovation: Three-Level Configuration

### Level 1: Simple IDs (Zero JSON)
```bash
cap-multi-recorder record --display 0 output.mp4
```
Perfect for quick recordings with sensible defaults.

### Level 2: Inline JSON Settings
```bash
cap-multi-recorder record \
--display '{"id":0,"settings":{"fps":60}}' output.mp4
```
Per-source control without creating files.

### Level 3: File References
```bash
cap-multi-recorder record --display @config.json output.mp4
```
Reusable, version-controlled configurations.

### Level 4: Full Config Files
```bash
cap-multi-recorder record streaming-setup.json
```
Complete recording setups with named inputs and outputs.

## Planning Documents

- **[PLAN.md](./PLAN.md)** - Main implementation plan
- **[PLAN-UNIFIED.md](./PLAN-UNIFIED.md)** - Detailed unified approach
- **[PLAN-JSON-CONFIG.md](./PLAN-JSON-CONFIG.md)** - Full config format
- **[INPUT-PATTERNS.md](./INPUT-PATTERNS.md)** - Pattern comparison guide
- **[README.md](./README.md)** - Overview and quick start

## Architecture Highlights

- Built on `cap-recording` crate's `OutputPipeline`
- N→M routing: any sources to any outputs
- Platform-native encoders (AVFoundation, Media Foundation)
- Shared input sources across outputs
- Independent pipeline control per output

## Example Scenarios

### Screen + Camera + Mic to One File
```bash
cap-multi-recorder record \
--display 0 recording.mp4 \
--camera 0 recording.mp4 \
--microphone "Blue Yeti" recording.mp4
```

### Each Source to Separate File
```bash
cap-multi-recorder record \
--display 0 screen.mp4 \
--camera 0 webcam.mp4 \
--microphone "Blue Yeti" audio.ogg
```

### Complex Multi-Output
```bash
cap-multi-recorder record \
--display 0 screen.mp4 full.mp4 \
--camera 0 webcam.mp4 full.mp4 \
--microphone "Blue Yeti" audio.ogg full.mp4
```
Creates 3 files: screen-only, webcam-only, and combined.

## What's Next

Implementation will follow the phases outlined in PLAN.md:
1. Core infrastructure
2. Input discovery & management
3. Output pipeline construction
4. Recording control
5. Error handling & validation
6. User experience

See PLAN.md for detailed implementation roadmap.
32 changes: 32 additions & 0 deletions apps/multi-recorder/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[package]
name = "cap-multi-recorder"
version = "0.1.0"
edition = "2024"

[dependencies]
cap-recording = { path = "../../crates/recording" }
cap-media-info = { path = "../../crates/media-info" }
cap-timestamp = { path = "../../crates/timestamp" }
scap-targets = { path = "../../crates/scap-targets" }
clap = { version = "4.0", features = ["derive"] }
json5 = "0.4"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
anyhow = "1.0"
tokio = { version = "1.0", features = ["full"] }
flume = { workspace = true }
ffmpeg = { workspace = true }
kameo = { workspace = true }
futures = { workspace = true }

[target.'cfg(target_os = "macos")'.dependencies]
cap-enc-avfoundation = { path = "../../crates/enc-avfoundation" }
scap-screencapturekit = { path = "../../crates/scap-screencapturekit" }
cidre = { workspace = true, default-features = false }

[target.'cfg(windows)'.dependencies]
scap-direct3d = { path = "../../crates/scap-direct3d" }
windows = { version = "0.60", features = ["Win32_Graphics_Direct3D11", "Win32_Graphics_Dxgi"] }

[lints]
workspace = true
Loading