SkillAgentSearch skills...

Crabcamera

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.

Install / Use

/learn @Michael-A-Kuykendall/Crabcamera

README

🦀 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

Related Skills

View on GitHub
GitHub Stars146
CategoryContent
Updated3d ago
Forks15

Languages

Rust

Security Score

100/100

Audited on Mar 20, 2026

No findings