record: size recordings from the screen, not the quality preset

The quality preset chose the OBS canvas while the capture ran at the
game's real size, and the scene item carries no transform, so picking
1080p on a 1440p screen recorded only the top-left 1920x1080 crop of
the game.

Recordings now always run at the primary monitor's resolution, queried
in device pixels so display scaling cannot skew them, and a recording
start re-checks the screen so a display change mid-session cannot
bring the crop back. Quality presets keep their bitrate meaning and
nothing else; they never reached the encoder before, so High, Ultra
and friends now actually change what a recording costs on disk.
This commit is contained in:
vhaudiquet committed 2026-11-21 18:15:52 +01:00
1 parent 1d7f87f71d
commit b1cde7e783
5 files changed
+106 -75

No files matched your search

+21 -40
View File
@@ -89,43 +89,26 @@ pub enum AmfQuality {
Quality,
}
/// Quality level presets that configure resolution and other parameters.
/// Quality level presets as bitrate tiers.
///
/// Recordings always run at the screen's resolution; these only trade file size
/// against detail. Frame rate comes from `VideoSettings::frame_rate`.
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, Default)]
#[serde(rename_all = "lowercase")]
pub enum QualityLevel {
/// 720p @ 30fps, lower bitrate.
/// 4500 kbps, smaller files.
Low,
/// 1080p @ 30fps, moderate bitrate.
/// 6000 kbps.
Medium,
/// 1080p @ 60fps, high bitrate.
/// 8000 kbps.
#[default]
High,
/// 1440p @ 60fps, maximum quality.
/// 12000 kbps, largest files.
Ultra,
}
impl QualityLevel {
/// Get the target resolution for this quality level.
pub fn resolution(&self) -> (u32, u32) {
match self {
QualityLevel::Low => (1280, 720),
QualityLevel::Medium => (1920, 1080),
QualityLevel::High => (1920, 1080),
QualityLevel::Ultra => (2560, 1440),
}
}
/// Get the recommended frame rate for this quality level.
pub fn frame_rate(&self) -> u32 {
match self {
QualityLevel::Low => 30,
QualityLevel::Medium => 30,
QualityLevel::High => 60,
QualityLevel::Ultra => 60,
}
}
/// Get the recommended bitrate in kbps for this quality level.
/// Get the bitrate in kbps this quality level records at.
pub fn recommended_bitrate(&self) -> u32 {
match self {
QualityLevel::Low => 4500,
@@ -342,15 +325,6 @@ impl EncoderPreset {
}
}
/// Get the effective bitrate for this preset.
pub fn effective_bitrate(&self) -> u32 {
match self {
EncoderPreset::Nvenc { bitrate, .. } => *bitrate,
EncoderPreset::Amf { bitrate, .. } => *bitrate,
EncoderPreset::X264 { bitrate, .. } => *bitrate,
}
}
/// Create a preset optimized for the given quality level.
pub fn for_quality(quality: QualityLevel, capability: EncoderCapability) -> Self {
let bitrate = quality.recommended_bitrate();
@@ -384,10 +358,10 @@ mod tests {
use super::*;
#[test]
fn test_quality_level_resolution() {
assert_eq!(QualityLevel::Low.resolution(), (1280, 720));
assert_eq!(QualityLevel::High.resolution(), (1920, 1080));
assert_eq!(QualityLevel::Ultra.resolution(), (2560, 1440));
fn test_quality_level_bitrate() {
assert_eq!(QualityLevel::Low.recommended_bitrate(), 4500);
assert_eq!(QualityLevel::High.recommended_bitrate(), 8000);
assert_eq!(QualityLevel::Ultra.recommended_bitrate(), 12000);
}
#[test]
@@ -410,7 +384,14 @@ mod tests {
#[test]
fn test_preset_for_quality() {
let preset = EncoderPreset::for_quality(QualityLevel::High, EncoderCapability::Nvenc);
assert_eq!(preset.effective_bitrate(), 8000);
assert_eq!(
preset,
EncoderPreset::Nvenc {
bitrate: 8000,
cq_level: 20,
two_pass: true
}
);
assert!(preset.is_hardware());
}
}
+7
View File
@@ -46,6 +46,13 @@ pub struct VideoSettings {
pub hardware_acceleration: bool,
}
impl VideoSettings {
/// The bitrate a recording runs at: the quality tier's.
pub fn video_bitrate(&self) -> u32 {
self.quality.recommended_bitrate()
}
}
impl Default for VideoSettings {
fn default() -> Self {
Self {