refactor(streamer): remove gstreamer and legacy rtmp paths
This commit is contained in:
+50
-239
@@ -1,286 +1,97 @@
|
||||
# Operational Caveats
|
||||
|
||||
This document captures known environment constraints, behavioral edge cases, and operational considerations for the cv-mmap streamer.
|
||||
This document captures the current runtime constraints for `cvmmap-streamer` after the FFmpeg-only cleanup.
|
||||
|
||||
## Environment Constraints
|
||||
## Input Model
|
||||
|
||||
### Simulator Label Length Limit
|
||||
### cvmmap URI Only
|
||||
|
||||
The cv-mmap simulator uses POSIX shared memory naming that imposes a 24-byte maximum on the `--label` parameter.
|
||||
|
||||
**Constraint:**
|
||||
- Maximum label length: 24 bytes
|
||||
- Exceeding this causes immediate exit with code 2
|
||||
|
||||
**Error message:**
|
||||
```
|
||||
--label exceeds 24 bytes
|
||||
```
|
||||
|
||||
**Workaround:**
|
||||
Use compact deterministic labels:
|
||||
```bash
|
||||
# Good (19 bytes)
|
||||
./build/cvmmap_streamer --run-mode pipeline --input-mode dummy --dummy-label acc_1_rtp_h264 ...
|
||||
|
||||
# Bad (28 bytes, will fail)
|
||||
./build/cvmmap_streamer --run-mode pipeline --input-mode dummy --dummy-label acceptance_rtp_h264_test ...
|
||||
```
|
||||
|
||||
### Deterministic Simulator Sizing
|
||||
|
||||
Small frame sizes can trigger GStreamer caps negotiation failures before the first encoded access unit on certain hosts.
|
||||
|
||||
**Constraint:**
|
||||
- Minimum recommended frame size: 640x360
|
||||
- Smaller sizes may cause `not-negotiated` pipeline errors
|
||||
|
||||
**Recommended simulator parameters for validation:**
|
||||
```bash
|
||||
./build/cvmmap_streamer \
|
||||
--run-mode pipeline \
|
||||
--input-mode dummy \
|
||||
--dummy-label acc_1_rtp_h264 \
|
||||
--dummy-width 640 \
|
||||
--dummy-height 360 \
|
||||
--dummy-fps 200 \
|
||||
--dummy-frames 320
|
||||
```
|
||||
|
||||
### Build Path Isolation
|
||||
|
||||
The downstream project must use its own build directory. Sharing the root `build/` folder with the main cv-mmap project causes cache collision.
|
||||
|
||||
**Constraint:**
|
||||
- Use `downstream/cvmmap-streamer/build`
|
||||
- Do not use root `build/`
|
||||
|
||||
**Error symptom:**
|
||||
Configure errors referencing sibling repo paths or stale cache entries.
|
||||
|
||||
**Resolution:**
|
||||
```bash
|
||||
cmake --fresh -B downstream/cvmmap-streamer/build -S downstream/cvmmap-streamer
|
||||
```
|
||||
|
||||
### GStreamer Version Requirements
|
||||
|
||||
The NVENC pipeline requires GStreamer 1.20+ with full development headers. Missing elements are detected at configure time.
|
||||
|
||||
**Constraint:**
|
||||
- GStreamer 1.20+ required
|
||||
- Development headers required for build
|
||||
- `nvh264enc` and `nvh265enc` elements checked at runtime
|
||||
|
||||
**Missing NVENC error:**
|
||||
```
|
||||
FATAL: NVENC encoder not available (nvh264enc/nvh265enc)
|
||||
Run: gst-inspect-1.0 nvh264enc nvh265enc
|
||||
```
|
||||
|
||||
**Note:** The pipeline falls back to software encoding (`x264enc`, `x265enc`) if NVENC produces zero encoded access units after 60 frames.
|
||||
|
||||
## Dual-Mode H.265 RTMP Caveats
|
||||
|
||||
### Mode Selection is Binding
|
||||
|
||||
Once selected, the RTMP mode cannot be changed without restarting the streamer process. The mode determines packetization format for the entire session.
|
||||
|
||||
**Enhanced-RTMP mode:**
|
||||
- Uses `0x90`/`0x91` header bytes
|
||||
- FourCC signaling (`hvc1`)
|
||||
- Compatible with FFmpeg 6.0+, OBS 29+, SRS 6.0+, ZLMediaKit
|
||||
|
||||
**Domestic extension mode:**
|
||||
- Uses `0x1c`/`0x2c` header bytes
|
||||
- FLV codec-id 12 signaling
|
||||
- Legacy Chinese CDN compatibility
|
||||
- Not supported by all players
|
||||
|
||||
### Server Configuration Requirements
|
||||
|
||||
**ZLMediaKit:**
|
||||
Must set `enhanced=1` in config.ini for Enhanced-RTMP mode:
|
||||
```ini
|
||||
[rtmp]
|
||||
port=1935
|
||||
enhanced=1 # 1 = Enhanced RTMP, 0 = Domestic extension
|
||||
```
|
||||
|
||||
**SRS:**
|
||||
Use `hevc.flv.conf` or `hevc.ts.conf` for HEVC support:
|
||||
```bash
|
||||
docker run --rm -it -p 1935:1935 ossrs/srs:6 \
|
||||
./objs/srs -c conf/hevc.flv.conf
|
||||
```
|
||||
|
||||
### Player Compatibility
|
||||
|
||||
| Player | H.264 RTMP | H.265 Enhanced | H.265 Domestic |
|
||||
|--------|------------|----------------|----------------|
|
||||
| FFmpeg 6.0+ | Yes | Yes | With patch |
|
||||
| ffplay | Yes | Yes | Variable |
|
||||
| VLC 3.0+ | Yes | Yes | No |
|
||||
| Chrome 105+ (MSE) | Yes | HTTP-FLV/TS only | No |
|
||||
| OBS 29+ | Yes | Yes | No |
|
||||
|
||||
### Mode Mismatch Detection
|
||||
|
||||
The `rtmp_stub_tester` validates mode expectations and fails with exit code 6 on mismatch:
|
||||
The runtime ingests from a cvmmap URI, for example:
|
||||
|
||||
```bash
|
||||
# Start stub expecting domestic mode
|
||||
./build/rtmp_stub_tester --mode h265-domestic ...
|
||||
|
||||
# Streamer sends enhanced mode
|
||||
./build/cvmmap_streamer --codec h265 --rtmp-mode enhanced ...
|
||||
|
||||
# Result: tester exits 6 (ModeMismatch)
|
||||
./build/cvmmap_streamer --run-mode pipeline --input-uri 'cvmmap://zed@/tmp/cvmmap'
|
||||
```
|
||||
|
||||
## Low-Latency Configuration Trade-offs
|
||||
Legacy flags such as `--shm-name`, `--zmq-endpoint`, `--input-mode`, and the dummy-input options are no longer supported.
|
||||
|
||||
### Queue Size
|
||||
## Encoder Path
|
||||
|
||||
| Setting | Latency | Behavior |
|
||||
|---------|---------|----------|
|
||||
| `--queue-size 1` | Lowest | Latest-frame semantics, drops old frames |
|
||||
| `--queue-size 5` | Medium | Small backlog, some frame retention |
|
||||
| `--queue-size 0` | N/A | Unbounded (NOT recommended) |
|
||||
### FFmpeg Is The Only Encoder Backend
|
||||
|
||||
### Encoder Settings
|
||||
The public backend surface is:
|
||||
|
||||
| Setting | Low-Latency Value | Trade-off |
|
||||
|---------|-------------------|-----------|
|
||||
| `--b-frames 0` | Disabled | Slightly lower compression efficiency |
|
||||
| `--gop 30` | 1 second at 30fps | Larger GOP = better compression, higher seek latency |
|
||||
| `rc-lookahead` | 0 (NVENC) | Slightly lower quality prediction |
|
||||
| `zerolatency` | true | Disables encoder buffering |
|
||||
- `--encoder-backend auto`
|
||||
- `--encoder-backend ffmpeg`
|
||||
|
||||
### Server-Side Latency (Optional)
|
||||
Both resolve to the FFmpeg encoder path. The removed GStreamer backend is no longer available.
|
||||
|
||||
When using SRS or ZLMediaKit, additional latency can be introduced by server buffering.
|
||||
### NVENC Is Optional
|
||||
|
||||
**SRS low-latency settings:**
|
||||
```
|
||||
publish { mr off; }
|
||||
play { gop_cache off; queue_length 5; tcp_nodelay on; }
|
||||
When `--encoder-device nvidia` is selected, FFmpeg must expose `h264_nvenc` and `hevc_nvenc`.
|
||||
|
||||
Useful local checks:
|
||||
|
||||
```bash
|
||||
ffmpeg -hide_banner -encoders | rg 'nvenc|libx264|libx265'
|
||||
```
|
||||
|
||||
**Trade-offs:**
|
||||
- `gop_cache off`: Players wait for next I-frame (startup delay)
|
||||
- `mr off`: Higher CPU usage
|
||||
- `queue_length 5`: More susceptible to network jitter
|
||||
If NVENC is unavailable, use:
|
||||
|
||||
## Fault Scenario Behaviors
|
||||
|
||||
### Torn Frame Handling
|
||||
|
||||
When the coherent snapshot detects a torn read (metadata changed during copy):
|
||||
|
||||
1. Frame is dropped
|
||||
2. `torn_frames` counter increments
|
||||
3. Ingest loop continues
|
||||
4. Next sync message triggers new snapshot attempt
|
||||
|
||||
**Expected log:**
|
||||
```
|
||||
SNAPSHOT_TORN frame_count=A/B timestamp=X/Y
|
||||
```bash
|
||||
--encoder-device software
|
||||
```
|
||||
|
||||
### Stream Reset Handling
|
||||
### Low-Latency Defaults
|
||||
|
||||
When `MODULE_STATUS_STREAM_RESET` is received:
|
||||
The current low-latency defaults are:
|
||||
|
||||
1. Ingest queue is flushed
|
||||
2. Frame counters reset
|
||||
3. Pipeline may rebuild if resolution/format changed
|
||||
4. RTMP publishers send sequence header rebase
|
||||
5. `resets` counter increments
|
||||
- `gop=30`
|
||||
- `b_frames=0`
|
||||
- NVENC preset/tune tuned for low latency
|
||||
|
||||
**Expected log:**
|
||||
```
|
||||
STREAM_RESET_RECEIVED
|
||||
RTMP_STREAM_RESET_REBASE mode=<mode>
|
||||
```
|
||||
This favors immediacy over compression efficiency.
|
||||
|
||||
### Backpressure Containment
|
||||
## Transport Caveats
|
||||
|
||||
When downstream sinks are slower than ingest:
|
||||
### RTMP Is Enhanced RTMP Only
|
||||
|
||||
1. Queue fills to capacity
|
||||
2. Oldest frames evicted before push
|
||||
3. `dropped_frames` counter increments
|
||||
4. Latest frame always prioritized
|
||||
5. Latency remains bounded
|
||||
The repo now supports:
|
||||
|
||||
**Expected log:**
|
||||
```
|
||||
QUEUE_DROP dropped_frames=N queue_depth=1
|
||||
```
|
||||
- `libavformat` RTMP output
|
||||
- `ffmpeg_process` RTMP output
|
||||
|
||||
## Known Limitations
|
||||
The removed custom RTMP packetizer and `domestic` mode are no longer available. RTMP is always Enhanced RTMP.
|
||||
|
||||
### No Audio Support
|
||||
### RTP SDP Is Optional
|
||||
|
||||
Version 1.0 does not support audio capture or muxing. Video-only streams.
|
||||
The RTP publisher can write an SDP sidecar when `--rtp-sdp` is set. This is only for generic receivers that need an out-of-band description. If the consumer is preconfigured, skip the SDP output.
|
||||
|
||||
### No Direct RTSP/WebRTC Publishing
|
||||
|
||||
RTSP and WebRTC are not direct publisher outputs. They require server-side conversion from RTMP or RTP.
|
||||
This repo does not contain a direct RTSP publisher or a direct WebRTC/WHEP publisher.
|
||||
|
||||
### Single Codec Per Session
|
||||
If you want browser playback or WHEP, publish RTMP to a media server such as SRS and let that server expose WHEP/WebRTC.
|
||||
|
||||
Runtime codec switching is not supported. To change codecs, restart the streamer process.
|
||||
## Media Scope
|
||||
|
||||
### NVENC Requires NVIDIA GPU
|
||||
### No Audio Support
|
||||
|
||||
NVENC hardware encoding requires an NVIDIA GPU with encode support. Falls back to software encoding on non-NVIDIA systems or when NVENC is unavailable.
|
||||
This project is video-only. It publishes or records encoded video access units only.
|
||||
|
||||
### UDP RTP Only
|
||||
If you need audio transport, muxing, or A/V sync, that is outside the current repo scope.
|
||||
|
||||
RTP output uses UDP unicast only. No multicast or TCP interleaving support in v1.
|
||||
## Recording Caveats
|
||||
|
||||
## Debugging Tips
|
||||
### MCAP Stores Encoded Video Frames
|
||||
|
||||
### Enable Verbose Logging
|
||||
MCAP recording stores one `foxglove.CompressedVideo` message per encoded access unit. Replay depends on encoded keyframes carrying decoder configuration; this is handled by the current writer on keyframes.
|
||||
|
||||
All binaries use spdlog. Set the environment variable for debug output:
|
||||
## External Server Caveats
|
||||
|
||||
```bash
|
||||
export SPDLOG_LEVEL=debug
|
||||
./build/cvmmap_streamer ...
|
||||
```
|
||||
### Local SRS Defaults Can Hit `ulimit`
|
||||
|
||||
### Check Evidence Logs
|
||||
On this machine, stock SRS configs can fail at startup if `max_connections` exceeds the local `ulimit -n`. The checked-in smoke profile uses `max_connections 64` to avoid that local failure mode.
|
||||
|
||||
Failed runs leave detailed logs:
|
||||
### Server Latency Still Matters
|
||||
|
||||
```bash
|
||||
# Find latest run
|
||||
ls -lt .sisyphus/evidence/task-14-acceptance/ | head
|
||||
|
||||
# Examine specific row logs
|
||||
cat .sisyphus/evidence/task-14-acceptance/RUN_ID/1-rtp_h264/streamer.log
|
||||
```
|
||||
|
||||
### Verify Binary Existence
|
||||
|
||||
Before running scripts, verify all binaries are built:
|
||||
|
||||
```bash
|
||||
for bin in cvmmap_streamer rtp_receiver_tester rtmp_stub_tester; do
|
||||
test -x "build/$bin" || echo "Missing: $bin"
|
||||
done
|
||||
```
|
||||
|
||||
### Test Individual Components
|
||||
|
||||
```bash
|
||||
# Test simulator only
|
||||
./build/cvmmap_streamer --run-mode pipeline --help
|
||||
|
||||
# Test streamer config validation only
|
||||
./build/cvmmap_streamer --codec h264 --shm-name test --zmq-endpoint ipc:///tmp/test.ipc
|
||||
# (Will fail with "No output enabled" but validates config parsing)
|
||||
```
|
||||
Low encoder latency does not guarantee low end-to-end latency. SRS, ZLMediaKit, HTTP-FLV players, and browser buffering can all add delay on top of the encoder path.
|
||||
|
||||
Reference in New Issue
Block a user