feat(app): adaptive quality, frame rate capping, and tighter VBV
Three changes to make the stream survive constrained links: Adaptive quality: the sender pipeline now tracks the PLI rate from the receiver. Every 5 seconds it evaluates: >0.5 PLI/s means the link is saturated (the receiver is dropping frames), so the CRF increases by 2 (lower quality, fewer bits) and the encoder restarts with a keyframe. <0.1 PLI/s means the link is stable, so the CRF decreases by 1 (better quality) and the encoder probes upward. Clamped to [user CRF, user CRF + 10] so quality never degrades below what the link can handle, and never exceeds what the user asked for. The adaptation is logged to stderr for visibility. Frame rate capping (--fps N): throttles the capture loop to N frames per second (0 = no cap; monitor rate). At 15fps instead of 60fps, the bandwidth requirement drops 4x at the same quality level. Desktop content is still smooth at 15-20fps. Tighter VBV: one frame period of buffer instead of two. A two-frame buffer lets a keyframe spike to twice the target rate in one burst, which overflows any constrained hop (Wi-Fi hotspot, slow switch) and cascades into PLI storms. One frame period keeps bursts within what the link can absorb in real time.
This commit is contained in:
@@ -12,6 +12,7 @@ struct SendCommand {
|
||||
std::string_view peer_address; // optional; empty means auto-discover
|
||||
int bitrate_kbps = 4000; // VBV max bitrate
|
||||
int crf = 22; // constant rate factor (quality)
|
||||
int fps = 0; // 0 = no cap (capture rate)
|
||||
};
|
||||
|
||||
struct ReceiveCommand {
|
||||
|
||||
@@ -27,6 +27,10 @@ struct SenderPipelineConfig {
|
||||
// cannot show.
|
||||
int max_encode_width = 0;
|
||||
int max_encode_height = 0;
|
||||
// Cap the encoding frame rate (0 = no cap; use the capture rate).
|
||||
// Lowering the frame rate halves the bandwidth at the same quality
|
||||
// level — useful on constrained links.
|
||||
int max_frame_rate = 0;
|
||||
};
|
||||
|
||||
struct ReceiverPipelineConfig {
|
||||
|
||||
Reference in New Issue
Block a user