Skip to content

FilmCraft: An open-source, nonlinear video editor written by scratch in pure Rust

Say why H.265 and AV1 are unavailable without a hardware encoder (#3062)

Adam Bruncaj4c91c89fd893
diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv
index 2ac92decc..214499151 100644
--- a/crates/ui-egui/src/i18n/es.tsv
+++ b/crates/ui-egui/src/i18n/es.tsv
@@ -3617,3 +3617,5 @@
Open a sequence to search its graphics Abre una secuencia para buscar en sus gráficos
No text graphics in this sequence. Add text with the Type tool. Esta secuencia no tiene gráficos con texto. Añade texto con la herramienta Texto.
No matching text. Ningún texto coincide.
+ H.265 (HEVC) needs a hardware encoder (NVENC on NVIDIA GPUs, VideoToolbox on macOS); none was found on this machine, and FilmCraft has no software H.265 encoder yet. Choose H.264 or ProRes instead. H.265 (HEVC) necesita un codificador por hardware (NVENC en GPU NVIDIA, VideoToolbox en macOS); no se encontró ninguno en este equipo y FilmCraft aún no tiene un codificador H.265 por software. Elija H.264 o ProRes.
+ AV1 needs a hardware encoder; none was found on this machine, and FilmCraft has no software AV1 encoder yet. AV1 necesita un codificador por hardware; no se encontró ninguno en este equipo y FilmCraft aún no tiene un codificador AV1 por software.
diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv
index d0fb3d4e7..8446dac2b 100644
--- a/crates/ui-egui/src/i18n/ja.tsv
+++ b/crates/ui-egui/src/i18n/ja.tsv
@@ -3616,3 +3616,5 @@
Open a sequence to search its graphics シーケンスを開くとグラフィックスを検索できます
No text graphics in this sequence. Add text with the Type tool. このシーケンスにはテキストのグラフィックスがありません。文字ツールでテキストを追加してください。
No matching text. 一致するテキストはありません。
+ H.265 (HEVC) needs a hardware encoder (NVENC on NVIDIA GPUs, VideoToolbox on macOS); none was found on this machine, and FilmCraft has no software H.265 encoder yet. Choose H.264 or ProRes instead. H.265 (HEVC) にはハードウェアエンコーダー(NVIDIA GPU の NVENC、macOS の VideoToolbox)が必要です。このマシンには見つからず、FilmCraft にはまだソフトウェアの H.265 エンコーダーがありません。代わりに H.264 または ProRes を選んでください。
+ AV1 needs a hardware encoder; none was found on this machine, and FilmCraft has no software AV1 encoder yet. AV1 にはハードウェアエンコーダーが必要です。このマシンには見つからず、FilmCraft にはまだソフトウェアの AV1 エンコーダーがありません。
diff --git a/crates/ui-egui/src/i18n/zh-cn.tsv b/crates/ui-egui/src/i18n/zh-cn.tsv
index 244646f47..647661bad 100644
--- a/crates/ui-egui/src/i18n/zh-cn.tsv
+++ b/crates/ui-egui/src/i18n/zh-cn.tsv
@@ -3592,3 +3592,5 @@
Open a sequence to search its graphics 打开序列以搜索其中的图形
No text graphics in this sequence. Add text with the Type tool. 此序列中没有文本图形。请用文字工具添加文本。
No matching text. 没有匹配的文本。
+ H.265 (HEVC) needs a hardware encoder (NVENC on NVIDIA GPUs, VideoToolbox on macOS); none was found on this machine, and FilmCraft has no software H.265 encoder yet. Choose H.264 or ProRes instead. H.265 (HEVC) 需要硬件编码器(NVIDIA GPU 上的 NVENC、macOS 上的 VideoToolbox);本机未找到,且 FilmCraft 尚无软件 H.265 编码器。请改选 H.264 或 ProRes。
+ AV1 needs a hardware encoder; none was found on this machine, and FilmCraft has no software AV1 encoder yet. AV1 需要硬件编码器;本机未找到,且 FilmCraft 尚无软件 AV1 编码器。
diff --git a/crates/ui-egui/src/panels/export_mode.rs b/crates/ui-egui/src/panels/export_mode.rs
index f1cf5224d..6f944641b 100644
--- a/crates/ui-egui/src/panels/export_mode.rs
+++ b/crates/ui-egui/src/panels/export_mode.rs
@@ -336,6 +336,22 @@ fn combo_why(ui: &mut egui::Ui, reg: &mut Reg, id: &str, selected: &str, options
chosen
}
+/// Why a format cannot be exported on this machine, or None when it can. H.265 and AV1 have no
+/// software encoder: without a hardware one (NVENC on NVIDIA, VideoToolbox on macOS) they are
+/// greyed out with the reason, instead of failing at export time.
+fn unavailable_why(format: Format) -> Option<&'static str> {
+ if filmcraft_engine::export::available(format) {
+ return None;
+ }
+ Some(match format {
+ Format::Hevc => tl!(
+ "H.265 (HEVC) needs a hardware encoder (NVENC on NVIDIA GPUs, VideoToolbox on macOS); none was found on this machine, and FilmCraft has no software H.265 encoder yet. Choose H.264 or ProRes instead."
+ ),
+ Format::Av1 => tl!("AV1 needs a hardware encoder; none was found on this machine, and FilmCraft has no software AV1 encoder yet."),
+ _ => tl!("Not supported by FilmCraft's encoders yet"),
+ })
+}
+
fn opts(labels: &[&str]) -> Vec<(String, bool)> {
labels.iter().map(|l| (l.to_string(), true)).collect()
}
@@ -552,8 +568,9 @@ fn settings_column(app: &mut FilmcraftApp, ui: &mut egui::Ui, rect: Rect) {
}
});
row(ui, &t, tl!("Format"), |ui| {
- let labels: Vec<(String, bool)> = Format::ALL.iter().map(|f| (f.label().to_string(), filmcraft_engine::export::available(*f))).collect();
- if let Some(i) = combo(ui, &mut reg, "export.format", ex.settings.format.label(), &labels, ui.available_width() - 4.0) {
+ // a format without an encoder here says why: H.265 and AV1 have hardware encoders only
+ let labels: Vec<(String, Option<&str>)> = Format::ALL.iter().map(|f| (f.label().to_string(), unavailable_why(*f))).collect();
+ if let Some(i) = combo_why(ui, &mut reg, "export.format", ex.settings.format.label(), &labels, ui.available_width() - 4.0) {
let f = Format::ALL[i];
if f != ex.settings.format {
// a format switch starts from that format's defaults (keeping size / rate / range)
@@ -569,6 +586,12 @@ fn settings_column(app: &mut FilmcraftApp, ui: &mut egui::Ui, rect: Rect) {
}
}
});
+ // a preset can name a format this machine cannot encode (an H.265 preset without a hardware
+ // encoder): say so where the format is chosen, before the export fails
+ if let Some(why) = unavailable_why(ex.settings.format) {
+ let r = ui.label(egui::RichText::new(why).color(t.danger).small());
+ reg.add("export.format.unavailable", r.rect, why);
+ }
ui.add_space(8.0);
let s = &mut ex.settings;
if s.has_video() && section(ui, &mut reg, &mut ex.open_sections, "video", tl!("Video"), &t) {
diff --git a/crates/ui-egui/tests/it/export_ui.rs b/crates/ui-egui/tests/it/export_ui.rs
index 6a3375259..573a36ee3 100644
--- a/crates/ui-egui/tests/it/export_ui.rs
+++ b/crates/ui-egui/tests/it/export_ui.rs
@@ -248,6 +248,16 @@ fn h265_shows_the_h264_family_controls_without_the_h264_only_ones() {
}
let sum = d.ok("ui.elements", json!({"prefix": "export.summary"}))[0]["label"].as_str().unwrap().to_string();
assert!(sum.contains("HEVC Main") && sum.contains("Target 20.00 Mbps"), "{sum}");
+ // headless there is no hardware encoder: H.265 says so where the format is chosen (a preset
+ // can still name it), and its entry in the Format list is greyed out with the same reason
+ assert!(!filmcraft_engine::export::available(Format::Hevc), "no NVENC / VideoToolbox probe is registered here");
+ let why = d.ok("ui.elements", json!({"prefix": "export.format.unavailable"}))[0]["label"].as_str().unwrap().to_string();
+ assert!(why.contains("hardware encoder") && why.contains("H.265") && why.contains("H.264 or ProRes"), "{why}");
+ d.click("export.format");
+ let hevc = Format::ALL.iter().position(|f| *f == Format::Hevc).unwrap();
+ let entries = d.ok("ui.elements", json!({"prefix": format!("export.format.option.{hevc}")}));
+ assert_eq!(entries[0]["label"], "H.265 (HEVC)", "{entries}");
+ d.ok("ui.key", json!({"key": "Escape"}));
d.snapshot("export-h265");
}