|
1 | | -A WebRTC server implementation that streams H264 video files to WHEP clients. |
| 1 | +# WRTC Examples |
2 | 2 |
|
3 | | -### Basic Usage |
| 3 | +This directory contains example programs demonstrating various features of the wrtc library. |
4 | 4 |
|
5 | | -```bash |
6 | | -# Run with default settings (creates test file if needed) |
7 | | -cargo run --example whep_demo |
8 | | -``` |
| 5 | +## Opus Codec Demo |
9 | 6 |
|
10 | | -### Advanced Usage |
| 7 | +The `opus_demo.rs` example demonstrates how to use the Opus audio codec for encoding and decoding audio data. |
11 | 8 |
|
12 | | -```bash |
13 | | -# With custom H264 file |
14 | | -H264_FILE_PATH=/path/to/your/video.h264 cargo run --example whep_demo |
15 | | - |
16 | | -# With custom settings |
17 | | -WRTC_SERVER_ADDRESS=0.0.0.0:9090 \ |
18 | | -H264_FPS=25 \ |
19 | | -WRTC_APP_NAME=live \ |
20 | | -WRTC_STREAM_NAME=my_stream \ |
21 | | -cargo run --example whep_demo |
22 | | -``` |
| 9 | +### Features |
23 | 10 |
|
24 | | -### Environment Variables |
| 11 | +- Reads WAV audio files |
| 12 | +- Encodes audio data using Opus codec |
| 13 | +- Decodes encoded audio back to PCM |
| 14 | +- Writes decoded audio to new WAV file |
| 15 | +- Shows compression ratio statistics |
| 16 | +- Comprehensive logging with env_logger |
25 | 17 |
|
26 | | -- `WRTC_SERVER_ADDRESS`: Server bind address (default: `127.0.0.1:8080`) |
27 | | -- `H264_FILE_PATH`: Path to H264 file (default: `./test_video.h264`) |
28 | | -- `H264_FPS`: Frames per second for playback (default: `30`) |
29 | | -- `WRTC_APP_NAME`: WebRTC app name (default: `live`) |
30 | | -- `WRTC_STREAM_NAME`: WebRTC stream name (default: `test_stream`) |
| 18 | +### Usage |
31 | 19 |
|
32 | 20 | ```bash |
33 | | -RUST_LOG=debug WRTC_SERVER_ADDRESS=0.0.0.0:9090 H264_FILE_PATH=/home/blue/Code/rust/wayshot/lib/wrtc/data/test.h264 cargo run --example whep_demo |
| 21 | +# Run with default logging (info level) |
| 22 | +cargo run --example opus_demo |
| 23 | + |
| 24 | +# Run with debug logging for detailed frame information |
| 25 | +RUST_LOG=debug cargo run --example opus_demo |
| 26 | + |
| 27 | +# Run with only warnings and errors |
| 28 | +RUST_LOG=warn cargo run --example opus_demo |
| 29 | + |
| 30 | +# Run with custom log filtering |
| 31 | +RUST_LOG=opus_demo=debug cargo run --example opus_demo |
34 | 32 | ``` |
| 33 | + |
| 34 | +### What it does |
| 35 | + |
| 36 | +1. **Reads** `data/test.wav` (48kHz, stereo, 5 seconds) |
| 37 | +2. **Encodes** audio to Opus packets (250 frames) |
| 38 | +3. **Decodes** Opus packets back to audio |
| 39 | +4. **Saves** result to `/tmp/opus-coder.wav` |
| 40 | +5. **Shows** compression statistics (~31:1 compression ratio) |
| 41 | + |
| 42 | +### Dependencies |
| 43 | + |
| 44 | +- `hound` - WAV file I/O |
| 45 | +- `env_logger` - Structured logging |
| 46 | +- `log` - Logging facade |
| 47 | +- `wrtc::opus` - Opus codec implementation |
| 48 | + |
| 49 | +### Log Levels |
| 50 | + |
| 51 | +- **INFO**: Basic progress information (default) |
| 52 | +- **DEBUG**: Detailed frame-by-frame encoding/decoding info |
| 53 | +- **WARN**: Error messages for failed operations |
| 54 | +- **ERROR**: Critical errors that stop execution |
0 commit comments