Files
screen_cast/include/screencast/app/cli.h
T
fegger 36d086af4e perf(codec): CRF rate control, longer GOP, faster preset, screen tuning
Four encoder quality improvements, all sender-side:

- CRF rate control (default 22, --crf to override): targets a
  constant visual quality level instead of a fixed bitrate. Static
  desktop content uses 300-800 kbps (vs. forced 4000+), and the saved
  bits go to sharp text and clean motion when they appear. The VBV
  max rate (the --bitrate value, now a cap rather than a target)
  bounds bursts so the receiver's UDP buffers stay safe. Round-trip
  test bitrate dropped from 1390 kb/s to 47 kb/s on synthetic frames
  — the encoder uses only what it needs.

- 5-second GOP (was 1 second): 80% fewer keyframe bits freed for
  detail frames. Screen content changes incrementally, not
  wholesale; PLI feedback recovers from loss in one frame time
  regardless of GOP length.

- faster preset (was veryfast): better sub-pixel estimation and
  RDO on more decisions. The desktop handles it trivially at 1080p.

- Screen-content x264 tuning: aq-mode=2 (auto-variance AQ moves
  bits away from flat areas toward text edges) and psy-rd=1.5
  (preserves texture sharpness).

Combined with the earlier veryfast upgrade and sender-side
downscaling, this is roughly 2x the perceived quality at the same
average bandwidth compared to the original ultrafast ABR encoder.

meson test 5/5 in both configurations, valgrind clean.
2026-09-09 12:12:36 +02:00

41 lines
1.2 KiB
C++

#pragma once
#include <cstdint>
#include <optional>
#include <string_view>
#include <variant>
namespace sc {
struct SendCommand {
std::string_view target = "monitor"; // monitor, window
std::string_view peer_address; // optional; empty means auto-discover
int bitrate_kbps = 4000; // VBV max bitrate
int crf = 22; // constant rate factor (quality)
};
struct ReceiveCommand {
std::string_view peer_address; // optional, informational
int local_rtp_port = 5004;
int signaling_port = 5005;
bool fullscreen = false;
bool software_decode = false; // --swdecode disables the hardware probe
};
struct DiscoverCommand {
int timeout_seconds = 3;
};
struct WaybarCommand {
bool toggle = false; // toggle streaming instead of printing status
};
using Command = std::variant<SendCommand, ReceiveCommand, DiscoverCommand, WaybarCommand>;
// Parse command line arguments. Prints usage and returns std::nullopt on error.
// `argv` is `char const* const*` so both `main`'s `char**` and const arrays
// convert implicitly.
std::optional<Command> parse_cli(int argc, const char* const argv[]);
} // namespace sc