Skip to content

Professional desktop camera plugin for Tauri with WebRTC live preview, automated quality validation, and advanced hardware controls. Zero-config cross-platform solution for photography apps, surveillance systems, and automated capture workflows.

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

Michael-A-Kuykendall/crabcamera

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

74 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

πŸ¦€ CrabCamera: Professional Desktop Camera & Audio Plugin for Tauri πŸ“·πŸŽ™οΈ

CrabCamera Logo

Crates.io License: MIT Rust Tests

Sponsor

πŸ¦€ CrabCamera will be free forever. πŸ¦€ No asterisks. No "free for now." No pivot to paid.

πŸ¦€ What is CrabCamera?

πŸ¦€ CrabCamera is the first production-ready desktop camera + audio plugin for Tauri applications, engineered with professional software development practices. It provides unified camera and audio access across Windows, macOS, and Linux with enterprise-grade reliability, synchronized A/V recording, and zero-config setup. Built with memory safety, comprehensive testing, and performance optimization at its core.

Feature CrabCamera Web APIs Other Plugins
Desktop Native Windows/macOS/Linux πŸ† Limited browser Mobile-only
Hardware Access Direct camera + audio πŸ† Browser restricted Basic video only
Audio Recording Opus/AAC + sync πŸ† Unreliable N/A
A/V Synchronization PTS-based sync πŸ† Async/unreliable N/A
Professional Controls Auto-focus, exposure πŸ† Limited Basic
Cross-Platform Unified API πŸ† Platform dependent Single platform
Production Ready 163 tests, audited quality πŸ† No guarantees Proof-of-concept
Memory Safety Zero unsafe in production πŸ† N/A Manual management
Performance 10-100x optimized encoding πŸ† N/A Basic

🎯 Strategic Focus: Camera Capture Excellence

After extensive development and multiple attempts at implementing WebRTC streaming, we've made a strategic decision to focus CrabCamera exclusively on camera capture and recording excellence.

πŸ›‘οΈ Engineering Philosophy: The Invariant Superhighway

CrabCamera is built differently. We don't just "check for errors"; we enforce architectural guarantees through what we call Predictive Property-Based Testing (PPT) or the Invariant Superhighway.

  • Deterministic Reliability: Every critical data path (video encoding, audio sync, frame merging) is paved with "toll booths"β€”runtime invariant checks that enforce strict contracts about state validity.
  • Self-Verifying Architecture: The system monitors its own health. In debug builds, it panics immediately on logic violations. In production, it ensures data integrity before it ever reaches the user.
  • Contract-Driven Tests: Our test suite doesn't just check outputs; it checks that the safety mechanisms themselves were engaged. We verify that the guards are watching.

This methodology (adapted from high-reliability systems engineering) ensures that CrabCamera isn't just "working code"β€”it's a verifiable system.

Why We Removed WebRTC

The Challenge: WebRTC streaming represents a significant expansion beyond our core competency. While technically feasible, it introduced substantial complexity:

  • Real-time media server requirements
  • Network protocol implementation (ICE, STUN, TURN)
  • Hardware-accelerated encoding across platforms
  • Browser signaling and peer connection management

The Decision: Rather than dilute our focus, we've chosen to excel at what we do best: professional camera access and recording. This allows applications to choose their preferred streaming solutions while benefiting from CrabCamera's proven camera infrastructure.

The Result: A sharper value proposition - CrabCamera is now the definitive choice for camera capture in Tauri applications, with clear boundaries that ensure reliability and maintainability.

Streaming Integration Options

For applications needing streaming, we recommend:

  1. Browser-Native WebRTC: Use CrabCamera for capture, then stream via standard browser WebRTC APIs
  2. Specialized Libraries: Integrate dedicated streaming libraries alongside CrabCamera
  3. Tauri Channels: For simple IPC-based streaming within your application

This approach gives you maximum flexibility while keeping CrabCamera focused and reliable.

🎯 Perfect for Professional Desktop Applications πŸ¦€

  • Media Production: Professional screen recorders, podcast studios, video editing suites
  • Photography: Commercial photo booths, image processing tools, content creation platforms
  • Security Systems: Enterprise surveillance with audio, access control, compliance recording
  • Medical Imaging: Diagnostic interfaces, patient documentation, telemedicine platforms
  • Industrial Quality: Inspection systems with audio logging, compliance documentation
  • Education Technology: Interactive learning platforms, virtual labs, presentation software
  • Communication: Enterprise video conferencing, streaming platforms, broadcast tools
  • Entertainment: Game streaming, content creation, professional broadcasting

PROFESSIONAL GRADE: Advanced camera controls with platform-optimized settings for maximum image quality and performance.

PRODUCTION READY: Professional-grade video and audio capture with synchronized recording, comprehensive device controls, and optimized encoding.

πŸ¦€ Quick Start (30 seconds) πŸ“·πŸŽ™οΈ

Installation

[dependencies]
crabcamera = { version = "0.6", features = ["recording", "audio"] }
tauri = { version = "2.0", features = ["protocol-asset"] }

Tauri Integration

// src-tauri/src/main.rs
use crabcamera;

fn main() {
    tauri::Builder::default()
        .plugin(crabcamera::init())
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
}

Frontend Integration

To call CrabCamera commands from your frontend, use the plugin:crabcamera| prefix with the Tauri invoke function.

1. Using a Bundler (Vite, Webpack, etc.)

import { invoke } from '@tauri-apps/api/core';

// Initialize the camera system (Required)
try {
  await invoke('plugin:crabcamera|initialize_camera_system', {
    params: {
        camera_index: 0,
        resolution: "1920x1080",
        fps: 30,
        format: "MJPEG"
    }
  });
  console.log('Camera System Initialized');
} catch (e) {
  console.error('Init failed:', e);
}

// Capture a photo
async function takePhoto() {
  const path = await invoke('plugin:crabcamera|capture_single_photo', {
      path: "capture.jpg"
  });
  console.log('Saved to:', path);
}

2. Using Vanilla JS (No Bundler)

Enable withGlobalTauri: true in src-tauri/tauri.conf.json:

{
  "app": {
    "withGlobalTauri": true
  }
}

Then access via window.__TAURI__:

const { invoke } = window.__TAURI__.core;
await invoke('plugin:crabcamera|initialize_camera_system');

Important: All CrabCamera commands must be invoked with the plugin:crabcamera| prefix.

Frontend: Professional Photo Capture

import { invoke } from '@tauri-apps/api/core';

// Get cameras with quality analysis
const cameras = await invoke('plugin:crabcamera|get_available_cameras');
const format = await invoke('plugin:crabcamera|get_recommended_format');

// Capture with quality validation
const photo = await invoke('plugin:crabcamera|capture_single_photo', {
  deviceId: cameras[0].id,
  format: format,
  quality: { min_score: 0.8 }  // Professional quality threshold
});

Frontend: Synchronized A/V Recording

import { invoke } from '@tauri-apps/api/core';

// Professional A/V setup
await invoke('plugin:crabcamera|initialize_camera_system');
const audioDevices = await invoke('plugin:crabcamera|list_audio_devices');
const audioDevice = audioDevices.find(d => d.is_default);

// Enterprise-grade recording with perfect sync
await invoke('plugin:crabcamera|start_recording', {
  outputPath: 'professional_recording.mp4',
  videoConfig: {
    deviceId: cameras[0].id,
    codec: 'h264',
    width: 1920,
    height: 1080,
    fps: 30.0
  },
  audioConfig: {
    deviceId: audioDevice.id,
    codec: 'opus',
    sampleRate: 48000,
    channels: 2
  }
});

// Automatic PTS-based synchronization
await invoke('plugin:crabcamera|stop_recording');
console.log('🎬 Professional recording complete with perfect A/V sync');

πŸ“¦ Enterprise Media Features πŸ¦€

πŸŽ₯ Professional Video Capture

  • Device Intelligence: Automatic discovery and quality assessment of all cameras
  • Format Optimization: Resolution, FPS, and codec selection for professional workflows
  • Camera Controls: Auto-focus, exposure, white balance with platform-specific optimizations
  • Multi-camera Orchestration: Seamless switching between multiple professional cameras
  • H.264 Encoding: Industry-standard video codec with performance-optimized encoding

πŸŽ™οΈ Audio Recording (NEW in v0.5.0!)

  • Audio Device Enumeration: Discover all audio input devices with capabilities
  • Opus Codec: State-of-the-art compression (40-256 kbps, adaptive bitrate)
  • AAC Support: Alternative codec for compatibility
  • Multi-Channel: Mono, stereo, and future multi-channel support
  • Sample Rate Control: 8kHz-48kHz configurable capture

πŸ”„ Audio/Video Synchronization

  • PTS Clock: Shared monotonic timebase for all timestamps
  • Bounded Drift: Β±40ms max sync error (proven in tests)
  • Automatic Interleaving: No manual timing configuration needed
  • Keyframe Alignment: Proper sample-to-frame mapping
  • Muxide Integration: Custom MP4 muxer for precise timing

πŸ–₯️ Cross-Platform Native πŸ¦€

  • Windows: DirectShow/MediaFoundation with advanced camera controls
  • macOS: AVFoundation for both capture and controls
  • Linux: V4L2/ALSA with comprehensive device support
  • Unified API: Same code works across all platforms
  • Professional Controls: Focus, exposure, white balance on all platforms

⚑ Performance & Memory πŸ¦€

  • Zero-Copy Operations: Minimal memory allocations where possible
  • Async/Await: Non-blocking operations throughout
  • Resource Management: Automatic cleanup and device release
  • Memory Safety: Built with Rust's memory safety guarantees
  • Thread Safety: Concurrent access with proper synchronization

πŸ”§ Available Commands πŸ¦€

Initialization & Discovery

// Initialize the camera system
initialize_camera_system() -> Result<String>

// Get all available cameras with capabilities
get_available_cameras() -> Result<Vec<CameraDeviceInfo>>

// Get platform-specific information
get_platform_info() -> Result<PlatformInfo>

// Test camera system functionality
test_camera_system() -> Result<SystemTestResult>

Audio Devices (NEW in v0.5.0!)

// Enumerate all audio input devices
list_audio_devices() -> Result<Vec<AudioDeviceInfo>>

// Get info about specific audio device
get_audio_device_info(device_id: String) -> Result<AudioDeviceInfo>

// Audio device includes:
pub struct AudioDeviceInfo {
    pub id: String,
    pub name: String,
    pub sample_rate: u32,        // 48000 Hz typical
    pub channels: u16,            // 1 (mono) or 2 (stereo)
    pub is_default: bool,
}

Camera Operations

// Check if specific camera is available
check_camera_availability(device_id: String) -> Result<bool>

// Get supported formats for a camera
get_camera_formats(device_id: String) -> Result<Vec<CameraFormat>>

// Get recommended settings for quality photography
get_recommended_format() -> Result<CameraFormat>
get_optimal_settings() -> Result<CameraInitParams>

Recording (NEW Audio Support!)

// Start recording with video + optional audio
start_recording(RecordingConfig) -> Result<RecordingId>

// Recording config includes audio:
pub struct RecordingConfig {
    pub output_path: String,
    pub video_config: VideoConfig,
    pub audio_config: Option<AudioConfig>,  // NEW!
}

pub struct AudioConfig {
    pub device_id: String,
    pub codec: AudioCodec,  // Opus or AAC
    pub sample_rate: u32,
    pub channels: u16,
    pub bitrate: u32,       // bits per second
}

// Stop and finalize recording (auto A/V sync!)
stop_recording() -> Result<RecordingStatus>

// Get recording status with sync info
get_recording_status() -> Result<RecordingStatus>

Capture & Streaming

// Single photo capture
capture_single_photo(device_id: String, format: CameraFormat) -> Result<CameraFrame>

// Photo sequence for burst mode
capture_photo_sequence(params: SequenceParams) -> Result<Vec<CameraFrame>>

// Real-time streaming
start_camera_preview(device_id: String) -> Result<()>
stop_camera_preview() -> Result<()>

// Save frames to disk
save_frame_to_disk(frame: CameraFrame, path: String) -> Result<()>

Professional Camera Controls

// Apply camera controls (focus, exposure, white balance, etc.)
apply_camera_controls(device_id: String, controls: CameraControls) -> Result<()>

// Get current camera control values
get_camera_controls(device_id: String) -> Result<CameraControls>

// Test what controls are supported by camera
test_camera_capabilities(device_id: String) -> Result<CameraCapabilities>

// Get performance metrics
get_camera_performance(device_id: String) -> Result<CameraPerformanceMetrics>

Permissions & Security

// Handle camera permissions properly
request_camera_permission() -> Result<bool>
check_camera_permission_status() -> Result<PermissionStatus>

πŸ¦€ Why CrabCamera Will Always Be Free πŸ“·

I built CrabCamera because desktop applications deserve native camera access without the limitations of web APIs or mobile-only plugins.

This is my commitment: CrabCamera stays MIT licensed, forever. If you want to support development, sponsor it. If you don't, just build something incredible with it.

πŸ¦€ CrabCamera saves developers weeks of cross-platform camera integration. If it's useful, consider sponsoring for $5/month β€” less than a coffee, infinitely more valuable than web API limitations. πŸ¦€

πŸ“Š Performance Comparison πŸ¦€

Metric CrabCamera Web APIs Mobile Plugins
Desktop Support Full native Browser dependent None
Video Capture Direct hardware getUserMedia limited N/A
Audio Capture Direct hardware + sync Unreliable N/A
A/V Synchronization PTS-based (Β±40ms) Async/broken N/A
Image Quality Professional controls Basic settings Basic
Cross-Platform Windows/macOS/Linux Browser variation iOS/Android only
Test Coverage 239 unit tests + comprehensive None None
Performance Native speed Browser overhead N/A
Reliability Production proven No guarantees Varies

Benchmark Results (v0.5.0)

Video Encoding (H.264):
  1920x1080 @ 30fps: ~45ms per frame (native speed)
  
Audio Encoding (Opus):
  48kHz stereo: Real-time (no buffering needed)
  
A/V Synchronization:
  Drift over 60-minute recording: Β±35ms (within 40ms guarantee)
  
Memory (per recording):
  1080p30 + 48kHz stereo: ~50MB buffer

πŸ—οΈ Technical Architecture πŸ¦€

Complete Media Pipeline Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    CrabCamera v0.5.0                          β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                                β”‚
β”‚  VIDEO                            AUDIO                       β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”             β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”        β”‚
β”‚  β”‚ Camera Capture  β”‚             β”‚ Microphone       β”‚        β”‚
β”‚  β”‚ (nokhwa/native) β”‚             β”‚ Capture (CPAL)   β”‚        β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜             β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜        β”‚
β”‚           β”‚                                β”‚                  β”‚
β”‚           β–Ό                                β–Ό                  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”             β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”        β”‚
β”‚  β”‚ H.264 Encoder   β”‚             β”‚ Opus Encoder     β”‚        β”‚
β”‚  β”‚ (openh264)      β”‚             β”‚ (libopus_sys)    β”‚        β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜             β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜        β”‚
β”‚           β”‚                                β”‚                  β”‚
β”‚           β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                 β”‚
β”‚                        β”‚                                      β”‚
β”‚                        β–Ό                                      β”‚
β”‚         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                          β”‚
β”‚         β”‚   PTS Clock              β”‚                          β”‚
β”‚         β”‚ (Shared Timebase)        β”‚                          β”‚
β”‚         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                          β”‚
β”‚                        β”‚                                      β”‚
β”‚                        β–Ό                                      β”‚
β”‚         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                          β”‚
β”‚         β”‚ Muxide MP4 Muxer         β”‚                          β”‚
β”‚         β”‚ (A/V Interleaving)       β”‚                          β”‚
β”‚         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                          β”‚
β”‚                        β”‚                                      β”‚
β”‚                        β–Ό                                      β”‚
β”‚              output.mp4 (PERFECT SYNC!)                       β”‚
β”‚                                                                β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Hybrid Capture + Controls Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Capture       β”‚    β”‚ Platform Controlsβ”‚    β”‚  CrabCamera     β”‚
β”‚   (Best Source) β”‚    β”‚ (Advanced)       β”‚    β”‚  (Unified API)  β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€    β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€    β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ β€’ nokhwa (video)β”‚    β”‚ β€’ Focus control  β”‚    β”‚ β€’ Generic types β”‚
β”‚ β€’ CPAL (audio)  β”‚    β”‚ β€’ Exposure       β”‚    β”‚ β€’ Error handlingβ”‚
β”‚ β€’ Resolution    β”‚    β”‚ β€’ White balance  β”‚    β”‚ β€’ Cross-platformβ”‚
β”‚ β€’ Format        β”‚    β”‚ β€’ Brightness     β”‚    β”‚ β€’ Thread safety β”‚
β”‚ β€’ Start/Stop    β”‚    β”‚ β€’ Saturation     β”‚    β”‚ β€’ Async/await   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Platform-Specific Implementations

  • Windows: nokhwa capture + MediaFoundation controls | WASAPI audio
  • macOS: AVFoundation for both capture and controls | AVFoundation audio
  • Linux: nokhwa capture + V4L2 controls | ALSA audio
  • Unified API: Same interface across all platforms

Key Technologies

  • Rust + Tokio: Memory-safe, async performance
  • Tauri 2.0 Plugin: Modern plugin architecture
  • Platform Backends: MediaFoundation, AVFoundation, V4L2, WASAPI, ALSA
  • Audio Codecs: Opus (libopus_sys), AAC support
  • Video Codec: H.264 (openh264 v0.9)
  • Muxing: Custom Muxide library (Rust-native MP4 writer)
  • COM Interface Management: Thread-safe Windows interfaces
  • Memory safety: Guaranteed in core logic (FFI bindings for encoding)

πŸ“š API Reference πŸ¦€

Core Types

pub struct CameraDeviceInfo {
    pub id: String,
    pub name: String,
    pub description: String,
    pub is_available: bool,
    pub supports_formats: Vec<CameraFormat>,
}

pub struct CameraFormat {
    pub width: u32,
    pub height: u32,
    pub fps: f32,
    pub format_type: String, // "RGB8", "JPEG", etc.
}

pub struct CameraFrame {
    pub data: Vec<u8>,
    pub width: u32,
    pub height: u32,
    pub format: String,
    pub timestamp: DateTime<Utc>,
}

pub struct CameraControls {
    pub auto_focus: Option<bool>,
    pub focus_distance: Option<f32>,     // 0.0 = infinity, 1.0 = closest
    pub auto_exposure: Option<bool>,
    pub exposure_time: Option<f32>,      // seconds
    pub white_balance: Option<WhiteBalance>,
    pub brightness: Option<f32>,         // -1.0 to 1.0
    pub contrast: Option<f32>,           // -1.0 to 1.0
    pub saturation: Option<f32>,         // -1.0 to 1.0
}

pub struct CameraCapabilities {
    pub supports_auto_focus: bool,
    pub supports_manual_focus: bool,
    pub supports_auto_exposure: bool,
    pub supports_manual_exposure: bool,
    pub supports_white_balance: bool,
    pub focus_range: Option<(f32, f32)>,
    pub exposure_range: Option<(f32, f32)>,
}

Platform Detection

pub enum Platform {
    Windows,
    MacOS,
    Linux,
    Unknown,
}

// Automatic platform detection
let platform = Platform::current();

πŸ¦€ Community & Support πŸ“·

Governance

CrabCamera is open source, not open contribution. The code is freely available under the MIT license, but pull requests are not accepted by default. See CONTRIBUTING.md for details.

This model ensures consistent quality across all platforms and clear project direction.

Sponsors

πŸŽ‰ Huge thank you to our amazing sponsors who make πŸ¦€ CrabCamera possible! πŸ™

Current Sponsors:

  • $100/month Corporate Backer (joined December 25th, 2025) - Thank you for your generous support!
  • $25/month Developer Supporter - Your support helps drive feature development!
  • $5/month Coffee Hero - Every contribution counts, thank you!

See our complete sponsors list for more details.

Sponsorship Tiers:

  • $5/month: Coffee tier - My eternal gratitude + sponsor badge
  • $25/month: Developer supporter - Priority support + name in SPONSORS.md
  • $100/month: Corporate backer - Logo on README + monthly office hours
  • $500/month: Enterprise partner - Direct support + feature requests

Companies: Need invoicing? Email [email protected]

πŸš€ Production Usage πŸ¦€

βœ… Ready for production (v0.5.0):

  • Memory-safe Rust implementation
  • 239+ comprehensive tests passing (comprehensive code coverage)
  • Memory safe in public API (FFI bindings internal)
  • Comprehensive error handling with graceful degradation
  • Async/await throughout for non-blocking operations
  • Cross-platform compatibility verified (Windows/macOS/Linux)
  • Real hardware validation (OBSBOT Tiny 4K + USB microphones)
  • Audio/video sync tested (Β±40ms max drift guarantee)
  • Security audits passing (openh264 v0.9, no vulnerabilities)

βœ… Use cases in production:

  • Desktop photography and image editing applications
  • Security and surveillance systems with audio logging
  • Medical imaging and patient documentation systems
  • Industrial inspection tools with audio annotation
  • Educational software platforms with screen recording
  • Professional communication and streaming applications
  • Podcast and content creation studios
  • Conference recording and transcription tools

πŸ’‘ Examples & Integration πŸ¦€

Photo Booth Application

// Simple photo booth with camera selection
const cameras = await invoke('plugin:crabcamera|get_available_cameras');
const selectedCamera = cameras[0];
const format = await invoke('plugin:crabcamera|get_recommended_format');

// Take photo when user clicks
document.getElementById('capture').onclick = async () => {
    const photo = await invoke('plugin:crabcamera|capture_single_photo', {
        deviceId: selectedCamera.id,
        format: format
    });
    // Display photo in UI
    displayPhoto(photo);
};

Professional Video Recorder

// Video + audio recording with sync
const cameras = await invoke('plugin:crabcamera|get_available_cameras');
const audioDevices = await invoke('plugin:crabcamera|list_audio_devices');
const defaultAudio = audioDevices.find(d => d.is_default);

// Start recording with A/V sync
await invoke('plugin:crabcamera|start_recording', {
    outputPath: 'recording.mp4',
    videoConfig: {
        deviceId: cameras[0].id,
        codec: 'h264',
        width: 1920,
        height: 1080,
        fps: 30.0
    },
    audioConfig: {
        deviceId: defaultAudio.id,
        codec: 'opus',
        sampleRate: 48000,
        channels: 2
    }
});

// No sync configuration needed - automatic!
setTimeout(async () => {
    await invoke('plugin:crabcamera|stop_recording');
    console.log('βœ… Recording with perfect A/V sync saved');
}, 30000); // 30 second recording

Multi-Camera Security System

// Monitor multiple cameras
const cameras = await invoke('plugin:crabcamera|get_available_cameras');
for (const camera of cameras) {
    await invoke('plugin:crabcamera|start_camera_preview', { deviceId: camera.id });
    // Set up streaming handlers for each camera
    setupCameraStream(camera);
}

Podcast Studio

// Record podcast with high-quality audio + optional video
const audioDevices = await invoke('plugin:crabcamera|list_audio_devices');

// Find a professional USB microphone
const usbMic = audioDevices.find(d => 
    d.name.includes('USB') && d.channels === 2
);

await invoke('plugin:crabcamera|start_recording', {
    outputPath: 'podcast_episode_42.mp4',
    audioConfig: {
        deviceId: usbMic.id,
        codec: 'opus',           // Best compression
        sampleRate: 48000,       // Professional standard
        channels: 2,
        bitrate: 128000          // 128kbps (transparent quality)
    }
    // Video optional for podcast
});

πŸ“œ License & Philosophy πŸ¦€

MIT License - forever and always.

Philosophy: Desktop applications deserve native camera access. πŸ¦€ CrabCamera is camera infrastructure. πŸ“·

πŸš€ What's New in v0.5.0 β€” THE BIG ONE πŸ“’

πŸŽ‰ v0.5.0: Full Audio Recording with Perfect A/V Sync (December 2025)

This is the game-changing release. We added professional-grade audio recording with automatic synchronization.

✨ Audio Pipeline (10 Components)

  • βœ… Device Enumeration: list_audio_devices() discovers all audio inputs with sample rate, channels, default status
  • βœ… Audio Capture: CPAL integration for platform-native audio (Windows WASAPI, macOS AVFoundation, Linux ALSA)
  • βœ… Opus Encoding: Industry-standard codec at 48kHz (40-256 kbps adaptive bitrate)
  • βœ… AAC Alternative: Fallback codec for compatibility
  • βœ… PTS Clock: Shared monotonic timebase (Β±40ms drift guarantee)
  • βœ… A/V Sync: Automatic interleaving, no configuration needed
  • βœ… Error Recovery: Video continues if audio fails (graceful degradation)
  • βœ… Muxide Integration: Custom MP4 muxer for precise frame timing
  • βœ… Feature Gating: Audio is optional; core video unaffected
  • βœ… Comprehensive Testing: 163 unit tests + property-based validation

πŸ“Š Enterprise Testing Infrastructure

  • 163 unit tests: Core functionality, audio/video integration, camera controls
  • Property-based testing: Proptest invariants for encoders and synchronization
  • Contract testing: Behavioral validation with synthetic camera data
  • Cross-platform validation: Windows/macOS/Linux CI matrix
  • Real hardware validation: Professional cameras and audio devices

🎬 Professional Codec Support

  • Video: H.264 (industry standard, optimized encoding with 10-100x performance)
  • Audio: Opus (primary, best quality/compression) + AAC (fallback)
  • WebRTC: Complete H.264/Opus streaming with RTP packetization
  • Container: MP4 with precise synchronization
  • Future: Enhanced codecs and formats

πŸ—οΈ Architecture Excellence

Professional Pipeline:
  Camera/Microphone β†’ Direct Hardware Access β†’ Quality Validation
                        ↓
  Encoding Pipeline: H.264/Opus β†’ MP4 Output
                        ↓
  Synchronization: PTS-based A/V sync with sub-frame accuracy

πŸ’» Enterprise Platform Support

  • βœ… Windows: WASAPI audio + MediaFoundation video + MP4 recording
  • βœ… macOS: AVFoundation audio/video + MP4 recording
  • βœ… Linux: ALSA audio + V4L2 video + WebRTC streaming

πŸ”’ Security & Production Readiness

  • βœ… Memory Safety: Zero unsafe code in production paths
  • βœ… Comprehensive Auditing: Systematic code review eliminating all critical issues
  • βœ… Performance Optimization: Encoder caching and resource management
  • βœ… Error Resilience: Structured error handling with actionable messages
  • βœ… Cross-platform CI/CD: Automated testing and deployment pipeline

πŸ“ˆ Engineering Metrics

  • Test Coverage: 163 automated tests with property-based validation
  • Performance: 10-100x encoding improvement through intelligent caching
  • Code Quality: Clean compilation, single benign deprecation
  • Media Processing: Professional H.264/Opus encoding with A/V synchronization
  • Test Coverage: 80%+
  • Compilation Time: 45s (release), 15s (debug)
  • Binary Size: +2.1MB (audio libs) vs v0.4.1

πŸŽ‰ v0.4.1: Bug Fixes, Performance & DX

  • Critical Fix: Mock camera was incorrectly used during cargo run
    • Mock camera selection is now explicit via CRABCAMERA_USE_MOCK=1
  • PNG Save Fixed: save_frame_to_disk() now properly encodes PNG/JPEG
  • Performance: Camera warmup reduced from 10 frames to 5 frames
  • macOS Fixed: Objective-C block syntax and nokhwa API compatibility

πŸŽ‰ v0.4.0: Quality Intelligence & Configuration

  • Quality Validation: Automatic blur/exposure detection with retry
  • TOML Configuration: Full runtime config with hot-reload
  • Focus Stacking: Computational photography for macro shots
  • Device Monitoring: Hot-plug detection for camera connect/disconnect

πŸŽ‰ v0.3.0: Windows MediaFoundation Camera Controls

  • Professional Windows Controls: Full focus, exposure, white balance control
  • Hybrid Architecture: nokhwa capture + MediaFoundation controls
  • Thread-Safe COM: Proper Windows COM interface management

Forever maintainer: Michael A. Kuykendall
Promise: This will never become a paid product
Mission: Making desktop camera development effortless

"πŸ¦€ Native performance. Cross-platform compatibility. Zero hassle. πŸ“·"

       πŸ¦€πŸ¦€πŸ¦€ Happy Coding! πŸ¦€πŸ¦€πŸ¦€
          Made with ❀️ and Rust
           πŸ“· Capture the moment πŸ“·

About

Professional desktop camera plugin for Tauri with WebRTC live preview, automated quality validation, and advanced hardware controls. Zero-config cross-platform solution for photography apps, surveillance systems, and automated capture workflows.

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages