Render Queue: output files end in their format's extension once (#293)

Renders on macOS came out as `Comp 1.mov.ecproj`, and an image
sequence's every frame as `Comp 1_00001.png.ecproj`; another output
was `Comp 2.mov.mov`.

Cause: the save dialogs for anything but a project went through the
project dialog hook, which filters to `.ecproj`; macOS's save panel
appends the allowed extension to any other name. 0.4.0's Render Queue
Choose File… used it (#192 moved Output To to its own dialog since),
and Save Frame As, Save Current Preview, Export Lottie, Save a Copy As
XML, Collect Files, Watch Folder and the Premiere export form's Browse
still did. Nothing then fixed the name: Output To kept `.ecproj` (no
format claims it), and changing the format replaced only the last
extension (`Comp 2.mov.ecproj` → `Comp 2.mov.mov`). `[compName]` of a
comp named `Comp 2.mov` also doubled it.

Fix: `Hooks::save_dialog` asks the dialog for the default name's own
extension (`pick_save_file`), the project dialog only for projects or
on hosts without another (the web); the desktop dialog has no filter
for a name without an extension (folders). `OutputFormat::with_extension`
makes an output path end in the format's extension exactly once
(project extensions and repeats of the format's dropped, a missing one
added; `logo.png.mov` kept), used by Output To, format changes and
`resolve_output`, so existing projects and templates render to the
right name too. Output To picks the file type from the extension
before a stray `.ecproj`.

Test: output_names_end_in_the_format_extension_once (project),
output_to_ends_in_the_format_extension_once (engine) and
save_dialogs_offer_the_file_extension (ui); the engine and ui tests
fail with the fix reverted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
bflatastic
2026-10-09 16:51:12 +07:00
co-authored by Claude Opus 5.5
parent a62a298f0c
commit be926adb92
9 changed files with 191 additions and 30 deletions
+5 -2
View File
@@ -8,7 +8,7 @@
use effectcraft_project::render_queue::{
AlphaMode, AudioFormat, AudioOutput, Channels, ColorDepth, CurrentOrOff, DEFAULT_SEQUENCE_TEMPLATE, DEFAULT_TEMPLATE, EffectsMode, FieldRender,
OutputFormat, OutputModule, PostRenderAction, ProResProfile, Pulldown, RESIZE_PRESETS, RenderLog, RenderQuality, RenderQueueItem, RenderSettings,
RenderStatus, ResizeQuality, SwitchOverride, TimeSpan, post_render_parse,
RenderStatus, ResizeQuality, SwitchOverride, TimeSpan, post_render_parse, without_project_extension,
};
use effectcraft_project::render_templates::{RenderTemplates, TemplateKind, TemplateSlot};
use effectcraft_time::{FrameRate, Tick};
@@ -364,7 +364,8 @@ fn apply_output(om: &mut OutputModule, templates: &RenderTemplates, roi: Option<
if let Some(l) = b_p(p, "includeProjectLink") {
om.include_project_link = l;
}
if let Some(o) = str_p(p, "output").or(str_p(p, "path")) {
// (Without the `.ecproj` a save dialog filtered to projects appended, #293.)
if let Some(o) = str_p(p, "output").or(str_p(p, "path")).map(without_project_extension) {
om.output = o.to_string();
// Only an extension the format doesn't write changes it: `.mp4` is H.264's, HEVC's and AV1's.
if let Some(f) = OutputFormat::from_path(o).filter(|f| f.extension() != om.format.extension() && !o.contains("[fileExtension]")) {
@@ -379,6 +380,8 @@ fn apply_output(om: &mut OutputModule, templates: &RenderTemplates, roi: Option<
om.output = keep;
}
}
// The format's extension exactly once (`Comp 2.mov.mov` → `Comp 2.mov`).
om.output = om.format.with_extension(&om.output);
}
if *om != before {
// Output To alone doesn't make the module custom.
+4 -2
View File
@@ -321,7 +321,8 @@ impl Session {
.unwrap_or_else(|| "Untitled Project".into())
}
/// The output path of a queue item: template tokens expanded, relative paths resolved against
/// The output path of a queue item: template tokens expanded, ending in the format's
/// extension exactly once ([`OutputFormat::with_extension`]), relative paths resolved against
/// the project's folder (or the working directory). `None` when the comp is gone or the
/// output is empty ("Needs Output").
pub fn resolve_output(&self, item: &RenderQueueItem) -> Option<String> {
@@ -338,7 +339,8 @@ impl Session {
let pname = self.project_name();
let vars =
TemplateVars { comp_name: &name, project_name: &pname, width: w, height: h, frame_rate: rate.as_f64(), start_frame: f0, end_frame: f0 + n - 1 };
let p = expand_template(tpl, item.output.format, &vars);
// The format's extension exactly once, whatever the name or a save dialog added (#293).
let p = item.output.format.with_extension(&expand_template(tpl, item.output.format, &vars));
let path = std::path::Path::new(&p);
if path.is_absolute() {
return Some(p);
+28
View File
@@ -110,6 +110,34 @@ fn output_to_keeps_a_format_that_writes_the_extension() {
assert_eq!((&r["output"]["format"], &r["outputModuleSummary"]), (&json!("Hevc"), &a["outputModuleSummary"]), "{r}");
}
/// Output To ends in the format's extension exactly once (#293). A name from a save dialog
/// filtered to projects (`Comp 1.mov.ecproj`; for a PNG sequence every frame got `.png.ecproj`)
/// loses the `.ecproj` and picks the file type from the extension before it; a comp named
/// `Comp 2.mov` renders to `Comp 2.mov`, not `Comp 2.mov.mov`.
#[test]
fn output_to_ends_in_the_format_extension_once() {
let mut s = session();
let cases = [
("h264", "/out/Comp 1.mov.ecproj", OutputFormat::ProRes, "/out/Comp 1.mov"),
("png", "/out/Comp 1_[#####].png.ecproj", OutputFormat::PngSequence, "/out/Comp 1_[#####].png"),
("prores", "/out/Comp 2.mov.mov", OutputFormat::ProRes, "/out/Comp 2.mov"),
("prores", "/out/render", OutputFormat::ProRes, "/out/render.mov"),
];
for (format, out, want, path) in cases {
let a = s.execute("renderQueue.add", json!({"format": format})).unwrap();
let r = s.execute("renderQueue.setOutput", json!({"item": a["item"], "path": out})).unwrap();
let om = &s.project.render_queue.last().unwrap().output;
assert_eq!((om.format, om.output.as_str()), (want, path), "{format} → {out}");
assert!(r["outputPath"].as_str().unwrap().ends_with(&path[5..]), "{r}");
}
s.execute("comp.new", json!({"name": "Comp 2.mov", "width": 64, "height": 36, "frameRate": 30, "duration": 1})).unwrap();
for (format, name) in [("prores", "Comp 2.mov"), ("h264", "Comp 2.mov.mp4"), ("png", "Comp 2.mov_[#####].png")] {
let a = s.execute("renderQueue.add", json!({"format": format})).unwrap();
let path = a["outputPath"].as_str().unwrap();
assert_eq!(std::path::Path::new(path).file_name().unwrap().to_string_lossy(), name, "{format}: {path}");
}
}
/// An explicit RGB + Alpha request with the AV1 WebM codec (which has no alpha) is refused, not
/// silently rendered opaque (#166). Without `channels`, AV1 WebM renders RGB as before.
#[test]