M13.4: HEVC / AV1 output modules (MP4 hvc1/av01, WebM AV1), codec + Opus options in engine, UI, CLI

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Brandon Thomas
2026-10-03 05:01:43 -04:00
co-authored by Claude Opus 5.5
parent 3a8b401e81
commit 280f7d509c
15 changed files with 906 additions and 49 deletions
+69 -3
View File
@@ -7,7 +7,9 @@
//! registers an automation id: `renderQueue.render`, `renderQueue.stop`,
//! `renderQueue.item.<n>.{row,twirl,render,renderSettings,outputModule,outputTo,outputPath}`.
use effectcraft_engine::project::render_queue::{AudioOutput, Channels, OutputFormat, ProResProfile, RenderQuality, RenderQueueItem, RenderStatus, TimeSpan};
use effectcraft_engine::project::render_queue::{
AudioOutput, Channels, OpusApplication, OutputFormat, ProResProfile, RenderQuality, RenderQueueItem, RenderStatus, TimeSpan, WebmVideoCodec,
};
use egui::{Align2, Color32, Rect, Sense, Stroke, StrokeKind, pos2, vec2};
use serde_json::{Value, json};
@@ -96,7 +98,7 @@ fn output_menu(it: &RenderQueueItem, available: &[OutputFormat]) -> Vec<(String,
}
v.push(("-".into(), Value::Null));
v.push((mark(o.channels == Channels::Rgb, "Channels: RGB"), json!({"channels": "rgb"})));
if o.format.supports_alpha() {
if o.supports_alpha() {
v.push((mark(o.channels == Channels::Rgba, "Channels: RGB + Alpha"), json!({"channels": "rgba"})));
}
match o.format {
@@ -112,7 +114,29 @@ fn output_menu(it: &RenderQueueItem, available: &[OutputFormat]) -> Vec<(String,
v.push((mark(o.bitrate_kbps == kbps, &format!("Bitrate: {} Mbps", kbps / 1000)), json!({"bitrate": kbps})));
}
}
OutputFormat::JpegSequence | OutputFormat::WebM => {
OutputFormat::Hevc | OutputFormat::Av1 => codec_menu(o, &mut v),
OutputFormat::WebM => {
v.push(("-".into(), Value::Null));
for c in [WebmVideoCodec::Vp9, WebmVideoCodec::Av1] {
v.push((mark(o.webm_codec == c, &format!("Video Codec: {}", c.label())), json!({"webmCodec": c.label().to_ascii_lowercase()})));
}
if o.webm_codec == WebmVideoCodec::Av1 {
codec_menu(o, &mut v);
} else {
v.push(("-".into(), Value::Null));
for q in [60u8, 80, 90, 100] {
v.push((mark(o.quality == q, &format!("Quality: {q}")), json!({"quality": q})));
}
}
v.push(("-".into(), Value::Null));
for kbps in [24u32, 32, 64, 96, 128, 192, 256] {
v.push((mark(o.opus_bitrate_kbps == kbps, &format!("Opus Bitrate: {kbps} kbps")), json!({"audioBitrate": kbps})));
}
for (a, k) in [(OpusApplication::Audio, "audio"), (OpusApplication::Voip, "voice")] {
v.push((mark(o.opus_application == a, &format!("Opus Tuning: {}", a.label())), json!({"opusApplication": k})));
}
}
OutputFormat::JpegSequence => {
v.push(("-".into(), Value::Null));
for q in [60u8, 80, 90, 100] {
v.push((mark(o.quality == q, &format!("Quality: {q}")), json!({"quality": q})));
@@ -138,6 +162,48 @@ fn output_menu(it: &RenderQueueItem, available: &[OutputFormat]) -> Vec<(String,
v
}
/// HEVC / AV1 options: profile, level, rate control (bitrate or constant quality), key frames.
fn codec_menu(o: &effectcraft_engine::project::render_queue::OutputModule, v: &mut Vec<(String, Value)>) {
use effectcraft_engine::project::render_queue::{CodecProfile, RateControlMode, VideoCodecOptions};
let mark = |on: bool, l: &str| if on { format!("✓ {l}") } else { format!(" {l}") };
let c = &o.codec;
v.push(("-".into(), Value::Null));
for p in CodecProfile::ALL {
v.push((mark(c.profile == p, &format!("Profile: {}", p.label())), json!({"profile": format!("{p:?}").to_ascii_lowercase()})));
}
v.push(("-".into(), Value::Null));
v.push((mark(c.level.is_none(), "Level: Auto"), json!({"level": "auto"})));
// The common HEVC / AV1 levels (every level is reachable over the control channel).
for l in [30u8, 31, 40, 41, 50, 51, 52] {
debug_assert!(VideoCodecOptions::HEVC_LEVELS.contains(&l) && VideoCodecOptions::AV1_LEVELS.contains(&l));
let name = format!("{}.{}", l / 10, l % 10);
v.push((mark(c.level == Some(l), &format!("Level: {name}")), json!({"level": name})));
}
v.push(("-".into(), Value::Null));
for r in [RateControlMode::Bitrate, RateControlMode::Quality] {
v.push((mark(c.rate_control == r, &format!("Rate Control: {}", r.label())), json!({"rateControl": format!("{r:?}").to_ascii_lowercase()})));
}
if c.rate_control == RateControlMode::Bitrate {
for kbps in [1_000u32, 2_000, 5_000, 10_000, 20_000, 40_000] {
let l = if kbps < 2_000 { format!("Bitrate: {kbps} kbps") } else { format!("Bitrate: {} Mbps", kbps / 1000) };
v.push((mark(o.bitrate_kbps == kbps, &l), json!({"bitrate": kbps})));
}
} else {
for q in [40u8, 60, 70, 80, 90, 100] {
v.push((mark(c.quality == q, &format!("Quality: {q}")), json!({"quality": q})));
}
}
v.push(("-".into(), Value::Null));
for k in [0u32, 1, 12, 30, 60, 120, 250] {
let l = match k {
0 => "Key Frames: Auto (2 s)".to_string(),
1 => "Key Frames: Every Frame (all intra)".to_string(),
k => format!("Key Frames: Every {k} Frames"),
};
v.push((mark(c.keyframe_interval == k, &l), json!({"keyframeInterval": k})));
}
}
const OUTPUT_TEMPLATES: [&str; 4] = [
"[compName].[fileExtension]",
"[compName]_[width]x[height].[fileExtension]",