crabcamera 0.5.0

Advanced cross-platform camera integration for Tauri applications
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
# 🦀 CrabCamera: The Desktop Camera & Audio Plugin for Tauri 📷🎙️

```
     __________________________
    < Hello fellow Rustaceans! >
     --------------------------
            \
             \
                _~^~^~_
            \) /  o o  \ (/
              '_   -   _'
              / '-----' \
```

[![Crates.io](https://img.shields.io/crates/v/crabcamera.svg)](https://crates.io/crates/crabcamera)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Rust](https://img.shields.io/badge/rust-stable-brightgreen.svg)](https://rustup.rs/)
[![Tests](https://img.shields.io/badge/tests-115+-brightgreen.svg)](https://github.com/Michael-A-Kuykendall/crabcamera/releases)
[![Sponsor](https://img.shields.io/badge/❤️-Sponsor-ea4aaa?logo=github)](https://github.com/sponsors/Michael-A-Kuykendall)

**🦀 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. It provides unified camera and audio access across Windows, macOS, and Linux with professional controls, synchronized A/V recording, and zero-config setup. It's designed to be the **invisible infrastructure** that makes desktop media apps just work.

| 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** | **115+ tests, 80% coverage** 🏆 | No guarantees | Proof-of-concept |
| **Memory Safety** | Zero unsafe code 🏆 | N/A | Manual management |

## 🎯 Perfect for Desktop Applications 🦀

- **Media Creation**: Screen recorders, podcast editors, video production tools
- **Photography**: Photo booth apps, image editors, content creation tools with audio
- **Security**: Surveillance systems with audio monitoring, access control, live recording
- **Medical**: Imaging interfaces, patient documentation, diagnostic video tools
- **Industrial**: Quality control with audio logging, inspection systems, documentation
- **Education**: Interactive learning tools with recording, virtual labs, presentation software
- **Communication**: Video chat apps with perfect A/V sync, streaming tools, conference recording
- **Entertainment**: Game streaming, Twitch/YouTube capture with sync'd audio

**BONUS:** Professional camera controls with platform-optimized settings for maximum image quality.

## 🦀 Quick Start (30 seconds) 📷🎙️

### Installation

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

### Tauri Integration

```rust
// 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");
}
```

```json
// tauri.conf.json
{
  "plugins": {
    "crabcamera": {
      "audio": true
    }
  }
}
```

### Frontend: Capture a Photo

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

// Initialize camera system
await invoke('initialize_camera_system');

// Get available cameras
const cameras = await invoke('get_available_cameras');
const format = await invoke('get_recommended_format');

// Capture a photo
const photo = await invoke('capture_single_photo', {
  deviceId: cameras[0].id,
  format: format
});
```

### Frontend: Record Video + Audio

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

// Initialize both camera and audio
await invoke('initialize_camera_system');
const devices = await invoke('list_audio_devices');
const audioDevice = devices.find(d => d.is_default);

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

// Recording is automatically synchronized (no manual sync needed!)
await invoke('stop_recording');
console.log('✅ Recording saved with perfect A/V sync');
```

## 📦 Professional Media Features 🦀

### 🎥 Video Capture
- **Device Enumeration**: Automatic discovery of all connected cameras
- **Format Negotiation**: Resolution, FPS, and color format selection
- **Professional Settings**: Auto-focus, auto-exposure, white balance
- **Multi-camera Support**: Switch between multiple cameras seamlessly
- **H.264 Encoding**: Industry-standard video codec

### 🎙️ 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
```rust
// 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!)
```rust
// 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
```rust
// 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!)
```rust
// 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
```rust
// 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
```rust
// 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
```rust
// 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](https://github.com/sponsors/Michael-A-Kuykendall). 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** | **115 unit tests + 80%** | 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
- **Zero unsafe code**: Memory safety guaranteed (except platform bindings)

## 📚 API Reference 🦀

### Core Types
```rust
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
```rust
pub enum Platform {
    Windows,
    MacOS,
    Linux,
    Unknown,
}

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

## 🦀 Community & Support 📷

- **🐛 Bug Reports**: [GitHub Issues]https://github.com/Michael-A-Kuykendall/crabcamera/issues
- **💬 Discussions**: [GitHub Discussions]https://github.com/Michael-A-Kuykendall/crabcamera/discussions
- **📖 Documentation**: [docs.rs/crabcamera]https://docs.rs/crabcamera
- **💝 Sponsorship**: [GitHub Sponsors]https://github.com/sponsors/Michael-A-Kuykendall

### 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](CONTRIBUTING.md) for details.

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

### Sponsors

See our amazing [sponsors](SPONSORS.md) who make 🦀 CrabCamera possible! 🙏

**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 [michaelallenkuykendall@gmail.com](mailto:michaelallenkuykendall@gmail.com)

## 🚀 Production Usage 🦀

**✅ Ready for production (v0.5.0):**
- Memory-safe Rust implementation
- **115+ comprehensive tests passing** (80%+ code coverage)
- Zero unsafe code in public API
- 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
```javascript
// Simple photo booth with camera selection
const cameras = await invoke('get_available_cameras');
const selectedCamera = cameras[0];
const format = await invoke('get_recommended_format');

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

### Professional Video Recorder
```javascript
// Video + audio recording with sync
const cameras = await invoke('get_available_cameras');
const audioDevices = await invoke('list_audio_devices');
const defaultAudio = audioDevices.find(d => d.is_default);

// Start recording with A/V sync
await invoke('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('stop_recording');
    console.log('✅ Recording with perfect A/V sync saved');
}, 30000); // 30 second recording
```

### Multi-Camera Security System
```javascript
// Monitor multiple cameras
const cameras = await invoke('get_available_cameras');
for (const camera of cameras) {
    await invoke('start_camera_preview', { deviceId: camera.id });
    // Set up streaming handlers for each camera
    setupCameraStream(camera);
}
```

### Podcast Studio
```javascript
// Record podcast with high-quality audio + optional video
const audioDevices = await invoke('list_audio_devices');

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

await invoke('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**: 115 unit tests + 8 fuzz tests

#### 📊 Testing Arsenal
- **115 unit tests**: Audio device, encoder, clock, capture, recording integration
- **8 fuzz tests** (proptest): Property-based testing for encoder robustness
- **3 integration tests**: End-to-end A/V recording validation
- **80%+ code coverage**: Enforced per pull request
- **Real hardware**: Validated on OBSBOT Tiny 4K + standard USB microphones

#### 🎬 Codec Support
- **Video**: H.264 (industry standard, wide compatibility)
- **Audio**: Opus (primary, best quality/compression) + AAC (fallback)
- **Container**: MP4 with proper muxing
- **Future**: FLAC, WebM/VP9 (Q1 2026)

#### 🏗️ Architecture Highlights
```
Audio Pipeline:
  Microphone → CPAL Capture → PCM Frames → Opus Encoder → MP4 Muxing
  Video Pipeline:
  Camera → Nokhwa Capture → H.264 Encoder → MP4 Muxing
                            Synchronized Playback (PTS-based)
```

#### 💻 Platform Support
- **Windows**: WASAPI audio capture + MediaFoundation video
-**macOS**: AVFoundation audio + AVFoundation video
-**Linux**: ALSA audio + V4L2 video

#### 🔒 Security & Stability
- ✅ openh264 upgraded (0.6 → 0.9, RUSTSEC-2025-0008 fixed)
- ✅ Cross-platform CI/CD (Linux, macOS, Windows matrix)
- ✅ All platform-specific issues resolved
- ✅ Zero unsafe code in public API

#### 📈 Stats
- **Lines of Code**: ~3,000 new (audio module)
- **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`
- **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 📷
```