Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions crates/enc-ffmpeg/src/video/h264.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1261,6 +1261,7 @@ fn get_codec_and_options(
options.set("realtime", "false");
options.set("profile", "main");
options.set("allow_sw", "0");
options.set("g", &keyframe_interval_str);
} else {
options.set("realtime", "true");
options.set("prio_speed", "true");
Expand Down Expand Up @@ -1691,6 +1692,36 @@ mod self_test_tests {
.expect("healthy encoder passes the round trip");
}

#[cfg(target_os = "macos")]
#[test]
fn videotoolbox_export_uses_the_default_keyframe_interval() {
if force_software_encoder() {
return;
}
ffmpeg::init().ok();
let config = VideoInfo::from_raw(cap_media_info::RawVideoFormat::Nv12, 1920, 1080, 60);
let videotoolbox_options = |is_export| {
get_codec_and_options(
&config,
H264Preset::Medium,
Some(&["h264_videotoolbox"]),
is_export,
None,
)
.into_iter()
.find(|(codec, _)| codec.name() == "h264_videotoolbox")
.expect("VideoToolbox encoder is available on macOS")
Comment thread
richiemcilroy marked this conversation as resolved.
Resolved
.1
};

let export = videotoolbox_options(true);
let expected = (DEFAULT_KEYFRAME_INTERVAL_SECS * 60).to_string();
assert_eq!(export.get("g"), Some(expected.as_str()));

let realtime = videotoolbox_options(false);
assert_eq!(realtime.get("g"), None);
}

#[cfg(target_os = "linux")]
#[test]
fn linux_nvidia_device_prefers_nvenc_and_keeps_software_fallback() {
Expand Down
Loading