mirror of
https://github.com/storytold/effectcraft.git
synced 2026-11-28 09:09:39 +01:00
Export log shows where the time went: render, encode, write
When an export or Render Queue job ends, the render log (and the effectcraft_export log target) gets one summary line: wall time, busy time of rendering, the encoder and writing the file (they overlap, so not a sum), the compositor and why, the encoder and its settings, and frames per second. Formats that cannot time a stage apart say so. effectcraft-cli render --json returns it as timing and timingSummary. #3713
This commit is contained in:
1 parent
d6c9ad6643
commit
9fe7f5d5b6
15 files changed
+454
-43
No files matched your search
@@ -1018,7 +1018,10 @@ fn render(args: &Args, json_out: bool) -> Result<(), Failure> {
|
||||
match &it.status {
|
||||
RenderStatus::Done => {
|
||||
note!("done: {name} → {} in {:.2}s", it.last_output.as_deref().unwrap_or("?"), it.render_time.unwrap_or(0.0));
|
||||
results.push(json!({"comp": name, "output": it.last_output, "seconds": it.render_time}));
|
||||
if let Some(t) = &it.last_timing {
|
||||
note!("timing: {}", t.summary());
|
||||
}
|
||||
results.push(json!({"comp": name, "output": it.last_output, "seconds": it.render_time, "timing": it.last_timing, "timingSummary": it.last_timing.as_ref().map(|t| t.summary())}));
|
||||
}
|
||||
RenderStatus::Failed(e) => failed.push(format!("{name}: {e}")),
|
||||
other => failed.push(format!("{name}: {}", other.label())),
|
||||
|
||||
@@ -913,6 +913,7 @@ impl Session {
|
||||
status: RenderStatus::Failed(error),
|
||||
seconds: 0.0,
|
||||
output: None,
|
||||
timing: None,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,7 +136,9 @@ fn protocol_round_trips() {
|
||||
for r in [
|
||||
WorkerReply::Render { state: JobState { current: Some(3), done: 4, total: 10, items_total: 1, ..Default::default() } },
|
||||
WorkerReply::Item { update: ItemUpdate::Started { id: 3, unix: 1_700_000_000 } },
|
||||
WorkerReply::Item { update: ItemUpdate::Finished { id: 3, status: RenderStatus::Failed("x".into()), seconds: 1.5, output: Some("/a.gif".into()) } },
|
||||
WorkerReply::Item {
|
||||
update: ItemUpdate::Finished { id: 3, status: RenderStatus::Failed("x".into()), seconds: 1.5, output: Some("/a.gif".into()), timing: None },
|
||||
},
|
||||
WorkerReply::Progress { done: 1, total: 2 },
|
||||
WorkerReply::WarpPlan {
|
||||
key: [1, u64::MAX],
|
||||
|
||||
@@ -697,6 +697,7 @@ fn duplicate(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
it.started = None;
|
||||
it.render_time = None;
|
||||
it.last_output = None;
|
||||
it.last_timing = None;
|
||||
let id = it.id;
|
||||
proj.render_queue.insert(i + 1, it);
|
||||
Ok(id)
|
||||
|
||||
@@ -10,7 +10,9 @@
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use effectcraft_project::render_queue::{OutputFormat, OutputModule, PostRenderAction, RenderQueueItem, RenderStatus, TemplateVars, expand_template};
|
||||
use effectcraft_project::render_queue::{
|
||||
OutputFormat, OutputModule, PostRenderAction, RenderQueueItem, RenderStatus, RenderTiming, TemplateVars, expand_template,
|
||||
};
|
||||
use effectcraft_project::{ItemId, ItemKind, LayerSource, Project};
|
||||
use effectcraft_render::{ExprHost, FootageSource};
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -88,6 +90,9 @@ pub struct ExportResult {
|
||||
/// Files that went to storage overflow folders.
|
||||
#[serde(skip_serializing_if = "Vec::is_empty")]
|
||||
pub overflow: Vec<String>,
|
||||
/// Where the time went and what ran the job (the render log's summary line).
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub timing: Option<RenderTiming>,
|
||||
}
|
||||
|
||||
/// Encodes render queue items (implemented by the export layer).
|
||||
@@ -141,8 +146,19 @@ pub struct JobState {
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
#[serde(tag = "event", rename_all = "camelCase")]
|
||||
pub enum ItemUpdate {
|
||||
Started { id: u64, unix: u64 },
|
||||
Finished { id: u64, status: RenderStatus, seconds: f64, output: Option<String> },
|
||||
Started {
|
||||
id: u64,
|
||||
unix: u64,
|
||||
},
|
||||
Finished {
|
||||
id: u64,
|
||||
status: RenderStatus,
|
||||
seconds: f64,
|
||||
output: Option<String>,
|
||||
/// Where the time went (done items only).
|
||||
#[serde(default)]
|
||||
timing: Option<RenderTiming>,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
@@ -194,8 +210,12 @@ impl JobShared {
|
||||
item.insert("statusLabel".into(), json!(RenderStatus::Rendering.label()));
|
||||
item.insert("started".into(), json!(unix));
|
||||
item.insert("render_time".into(), Value::Null);
|
||||
item.remove("last_timing");
|
||||
}
|
||||
ItemUpdate::Finished { status, seconds, output, .. } => {
|
||||
ItemUpdate::Finished { status, seconds, output, timing, .. } => {
|
||||
if let Some(timing) = timing {
|
||||
item.insert("last_timing".into(), json!(timing));
|
||||
}
|
||||
item.insert("status".into(), json!(status));
|
||||
item.insert("statusLabel".into(), json!(status.label()));
|
||||
item.insert("render_time".into(), json!(seconds));
|
||||
@@ -361,7 +381,7 @@ async fn run_work(w: Work, shared: &JobShared, notify: &mut dyn FnMut(&JobShared
|
||||
for (k, modules) in w.items.iter().enumerate() {
|
||||
let Some((item, _)) = modules.first() else { continue };
|
||||
if shared.cancel.load(Ordering::Relaxed) {
|
||||
lock(&shared.updates).push(ItemUpdate::Finished { id: item.id, status: RenderStatus::UserStopped, seconds: 0.0, output: None });
|
||||
lock(&shared.updates).push(ItemUpdate::Finished { id: item.id, status: RenderStatus::UserStopped, seconds: 0.0, output: None, timing: None });
|
||||
continue;
|
||||
}
|
||||
let t1 = web_time::Instant::now();
|
||||
@@ -422,11 +442,11 @@ async fn run_work(w: Work, shared: &JobShared, notify: &mut dyn FnMut(&JobShared
|
||||
}
|
||||
let seconds = t1.elapsed().as_secs_f64();
|
||||
let up = match r {
|
||||
Ok(res) => ItemUpdate::Finished { id: item.id, status: RenderStatus::Done, seconds, output: Some(res.path) },
|
||||
Err(e) if e == CANCELLED => ItemUpdate::Finished { id: item.id, status: RenderStatus::UserStopped, seconds, output: None },
|
||||
Ok(res) => ItemUpdate::Finished { id: item.id, status: RenderStatus::Done, seconds, output: Some(res.path), timing: res.timing },
|
||||
Err(e) if e == CANCELLED => ItemUpdate::Finished { id: item.id, status: RenderStatus::UserStopped, seconds, output: None, timing: None },
|
||||
Err(e) => {
|
||||
log::warn!("render queue: item {} failed: {e}", item.id);
|
||||
ItemUpdate::Finished { id: item.id, status: RenderStatus::Failed(e), seconds, output: None }
|
||||
ItemUpdate::Finished { id: item.id, status: RenderStatus::Failed(e), seconds, output: None, timing: None }
|
||||
}
|
||||
};
|
||||
lock(&shared.updates).push(up);
|
||||
@@ -675,7 +695,13 @@ impl Session {
|
||||
let mut updates = lock(&sh.updates);
|
||||
for id in pending.into_iter().skip(completed) {
|
||||
if !updates.iter().any(|u| matches!(u, ItemUpdate::Finished { id: done, .. } if *done == id)) {
|
||||
updates.push(ItemUpdate::Finished { id, status: RenderStatus::Failed(error.to_string()), seconds: 0.0, output: None });
|
||||
updates.push(ItemUpdate::Finished {
|
||||
id,
|
||||
status: RenderStatus::Failed(error.to_string()),
|
||||
seconds: 0.0,
|
||||
output: None,
|
||||
timing: None,
|
||||
});
|
||||
}
|
||||
}
|
||||
lock(&sh.state).finished = true;
|
||||
@@ -707,7 +733,13 @@ impl Session {
|
||||
let done = finished.contains(id)
|
||||
|| self.project.render_queue.iter().any(|i| i.id == *id && matches!(i.status, RenderStatus::Done | RenderStatus::Failed(_)));
|
||||
if !done {
|
||||
lock(&j.shared.updates).push(ItemUpdate::Finished { id: *id, status: RenderStatus::UserStopped, seconds: 0.0, output: None });
|
||||
lock(&j.shared.updates).push(ItemUpdate::Finished {
|
||||
id: *id,
|
||||
status: RenderStatus::UserStopped,
|
||||
seconds: 0.0,
|
||||
output: None,
|
||||
timing: None,
|
||||
});
|
||||
}
|
||||
}
|
||||
lock(&j.shared.state).finished = true;
|
||||
@@ -739,15 +771,19 @@ impl Session {
|
||||
i.status = RenderStatus::Rendering;
|
||||
i.started = Some(*unix);
|
||||
i.render_time = None;
|
||||
i.last_timing = None;
|
||||
}
|
||||
}
|
||||
ItemUpdate::Finished { id, status, seconds, output } => {
|
||||
ItemUpdate::Finished { id, status, seconds, output, timing } => {
|
||||
if let Some(i) = p.render_queue.iter_mut().find(|i| i.id == *id) {
|
||||
i.status = status.clone();
|
||||
i.render_time = Some(*seconds);
|
||||
if output.is_some() {
|
||||
i.last_output = output.clone();
|
||||
}
|
||||
if timing.is_some() {
|
||||
i.last_timing = timing.clone();
|
||||
}
|
||||
if let (RenderStatus::Done, Some(o)) = (status, output)
|
||||
&& !i.post_render.is_none()
|
||||
{
|
||||
|
||||
@@ -9,7 +9,9 @@ use effectcraft_project::render_queue::{AudioFormat, Channels, OutputFormat, Pro
|
||||
use effectcraft_project::{Comp, ProjectSettings};
|
||||
use effectcraft_time::{FrameRate, Tick};
|
||||
use rayon::prelude::*;
|
||||
use web_time::Instant;
|
||||
|
||||
use crate::pipeline::Stage;
|
||||
use crate::{Cx, ExportError, Report, Result, State, batch_size, wants_audio};
|
||||
|
||||
fn enc(e: impl std::fmt::Display) -> ExportError {
|
||||
@@ -381,7 +383,7 @@ pub(crate) async fn movie(job: &Cx<'_>, comp: &Comp, w: u32, h: u32, st: &mut St
|
||||
.beside(beside, batch_frames((first_end..next_end).collect()), || -> Result<Vec<Packet>> {
|
||||
let mut pending = Vec::new();
|
||||
for (k, px) in first.iter().enumerate() {
|
||||
pending.extend(encode(&mut venc, px, k as u64)?);
|
||||
pending.extend(job.timed(Stage::Encode, || encode(&mut venc, px, k as u64))?);
|
||||
}
|
||||
Ok(pending)
|
||||
})
|
||||
@@ -465,8 +467,8 @@ pub(crate) async fn movie(job: &Cx<'_>, comp: &Comp, w: u32, h: u32, st: &mut St
|
||||
Ok(())
|
||||
};
|
||||
let frame_end_time = |k: u64| -> Tick { if k >= total { span_end } else { job.settings.frame_time(comp, k) } };
|
||||
write_video(&mut mux, pending)?;
|
||||
write_audio_until(&mut mux, frame_end_time(first_end), &mut cursor)?;
|
||||
job.timed(Stage::Write, || write_video(&mut mux, pending))?;
|
||||
job.timed_if(with_audio, Stage::Audio, || write_audio_until(&mut mux, frame_end_time(first_end), &mut cursor))?;
|
||||
let mut i = first_end;
|
||||
while i < total {
|
||||
let end = (i + batch).min(total);
|
||||
@@ -475,10 +477,10 @@ pub(crate) async fn movie(job: &Cx<'_>, comp: &Comp, w: u32, h: u32, st: &mut St
|
||||
let (done, next) = job
|
||||
.beside(beside, batch_frames((end..next_end).collect()), || -> Result<()> {
|
||||
for (k, px) in frames.iter().enumerate() {
|
||||
let ps = encode(&mut venc, px, i + k as u64)?;
|
||||
write_video(&mut mux, ps)?;
|
||||
let ps = job.timed(Stage::Encode, || encode(&mut venc, px, i + k as u64))?;
|
||||
job.timed(Stage::Write, || write_video(&mut mux, ps))?;
|
||||
}
|
||||
write_audio_until(&mut mux, frame_end_time(end), &mut cursor)
|
||||
job.timed_if(with_audio, Stage::Audio, || write_audio_until(&mut mux, frame_end_time(end), &mut cursor))
|
||||
})
|
||||
.await?;
|
||||
done?;
|
||||
@@ -486,17 +488,22 @@ pub(crate) async fn movie(job: &Cx<'_>, comp: &Comp, w: u32, h: u32, st: &mut St
|
||||
st.advance(end - i)?;
|
||||
i = end;
|
||||
}
|
||||
write_video(&mut mux, venc.flush()?)?;
|
||||
write_audio_until(&mut mux, span_end, &mut cursor)?;
|
||||
let tail = job.timed(Stage::Encode, || venc.flush())?;
|
||||
job.timed(Stage::Write, || write_video(&mut mux, tail))?;
|
||||
job.timed_if(with_audio, Stage::Audio, || write_audio_until(&mut mux, span_end, &mut cursor))?;
|
||||
if let Some((Audio::Aac(e), at)) = audio.as_mut() {
|
||||
let t = Instant::now();
|
||||
for au in e.flush() {
|
||||
mux.write_sample(*at, WriteSample { data: &au, duration: 1024, composition_offset: 0, is_sync: true }).map_err(mux_err)?;
|
||||
}
|
||||
job.add_time(Stage::Audio, t);
|
||||
}
|
||||
let t = Instant::now();
|
||||
let out = mux.finish().map_err(mux_err)?;
|
||||
out.flush().map_err(mux_err)?;
|
||||
let bytes = file.finish()?;
|
||||
Ok(Report { path, frames: 0, width: w, height: h, seconds: 0.0, bytes, audio: with_audio, log: None, overflow: vec![] })
|
||||
job.add_time(Stage::Write, t);
|
||||
Ok(Report { path, frames: 0, width: w, height: h, seconds: 0.0, bytes, audio: with_audio, log: None, overflow: vec![], timing: Default::default() })
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -44,7 +44,9 @@ mod webm_av1;
|
||||
|
||||
use web_time::Instant;
|
||||
|
||||
use effectcraft_project::render_queue::{AudioOutput, Channels, OutputFormat, OutputModule, RenderLog, RenderQuality, RenderSettings, sequence_path};
|
||||
use effectcraft_project::render_queue::{
|
||||
AudioOutput, Channels, OutputFormat, OutputModule, RenderLog, RenderQuality, RenderSettings, RenderTiming, sequence_path,
|
||||
};
|
||||
use effectcraft_project::{Comp, ItemId, Project};
|
||||
use effectcraft_raster::Image;
|
||||
use effectcraft_render::{ExprHost, FootageSource};
|
||||
@@ -168,7 +170,7 @@ impl Progress {
|
||||
}
|
||||
|
||||
/// What an export produced.
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[derive(Clone, Debug, Default, PartialEq)]
|
||||
pub struct Report {
|
||||
/// The movie file, or the first file of a sequence.
|
||||
pub path: String,
|
||||
@@ -182,6 +184,8 @@ pub struct Report {
|
||||
pub log: Option<String>,
|
||||
/// Files that went to an overflow folder.
|
||||
pub overflow: Vec<String>,
|
||||
/// Where the time went and what ran the job; the same as the summary line in the render log.
|
||||
pub timing: RenderTiming,
|
||||
}
|
||||
|
||||
/// Formats this build can write (all of them; kept as the hook for optional encoders).
|
||||
@@ -220,12 +224,23 @@ pub async fn export_async(job: &Job<'_>, progress: &mut dyn FnMut(&Progress) ->
|
||||
let render = RenderEnd(job.accel.filter(|_| job.options.caches.is_none()));
|
||||
let mut r = export_with(&cx, progress, t0).await;
|
||||
drop(render);
|
||||
let wall = t0.elapsed().as_secs_f64();
|
||||
if let Err(e) = &r {
|
||||
// A stopped or failed export gets its line too: slow ones are the ones people stop.
|
||||
let how = if matches!(e, ExportError::Cancelled) { "stopped" } else { "failed" };
|
||||
log::info!(target: "effectcraft_export", "{}: {}", cx.job.options.label, cx.timing(wall, 0).summary_of_unfinished(how));
|
||||
}
|
||||
if matches!(r, Err(ExportError::Cancelled)) {
|
||||
cx.remove_cancelled_outputs()?;
|
||||
return r;
|
||||
}
|
||||
let log = cx.write_log(&r, t0.elapsed().as_secs_f64());
|
||||
let timing = r.as_ref().ok().map(|rep| cx.timing(wall, rep.frames));
|
||||
if let Some(t) = &timing {
|
||||
log::info!(target: "effectcraft_export", "{}: {}", cx.job.options.label, t.summary());
|
||||
}
|
||||
let log = cx.write_log(&r, wall, timing.as_ref());
|
||||
if let Ok(rep) = &mut r {
|
||||
rep.timing = timing.unwrap_or_default();
|
||||
rep.log = log;
|
||||
rep.overflow = cx.overflowed.lock().unwrap_or_else(|e| e.into_inner()).clone();
|
||||
}
|
||||
@@ -341,7 +356,18 @@ async fn sequence(cx: &Cx<'_>, comp: &Comp, w: u32, h: u32, st: &mut State<'_>)
|
||||
st.advance(end - i)?;
|
||||
i = end;
|
||||
}
|
||||
Ok(Report { path: sequence_path(cx.path, f0), frames: 0, width: w, height: h, seconds: 0.0, bytes, audio: false, log: None, overflow: vec![] })
|
||||
Ok(Report {
|
||||
path: sequence_path(cx.path, f0),
|
||||
frames: 0,
|
||||
width: w,
|
||||
height: h,
|
||||
seconds: 0.0,
|
||||
bytes,
|
||||
audio: false,
|
||||
log: None,
|
||||
overflow: vec![],
|
||||
timing: Default::default(),
|
||||
})
|
||||
}
|
||||
|
||||
struct StillOutput {
|
||||
@@ -443,6 +469,7 @@ async fn gif_export(job: &Cx<'_>, comp: &Comp, w: u32, h: u32, st: &mut State<'_
|
||||
gif::Frame::from_rgba_speed(w as u16, h as u16, &mut px, 10)
|
||||
})
|
||||
.await;
|
||||
let t = Instant::now();
|
||||
for mut f in frames {
|
||||
clock += cs_per_frame;
|
||||
let d = (clock.round() as u64).saturating_sub(emitted).max(1);
|
||||
@@ -453,12 +480,16 @@ async fn gif_export(job: &Cx<'_>, comp: &Comp, w: u32, h: u32, st: &mut State<'_
|
||||
}
|
||||
enc.write_frame(&f).map_err(|e| ExportError::Encode(e.to_string()))?;
|
||||
}
|
||||
// The GIF writer compresses as it writes: the two are not measured apart.
|
||||
job.add_time(pipeline::Stage::EncodeWrite, t);
|
||||
st.advance(end - i)?;
|
||||
i = end;
|
||||
}
|
||||
let t = Instant::now();
|
||||
drop(enc);
|
||||
let bytes = file.finish()?;
|
||||
Ok(Report { path, frames: 0, width: w, height: h, seconds: 0.0, bytes, audio: false, log: None, overflow: vec![] })
|
||||
job.add_time(pipeline::Stage::EncodeWrite, t);
|
||||
Ok(Report { path, frames: 0, width: w, height: h, seconds: 0.0, bytes, audio: false, log: None, overflow: vec![], timing: Default::default() })
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -4,7 +4,9 @@
|
||||
|
||||
use std::sync::Mutex;
|
||||
|
||||
use effectcraft_project::render_queue::{AlphaMode, Channels, CurrentOrOff, EffectsMode, FrameSample, RenderLog, ResizeQuality, SwitchOverride, log_path};
|
||||
use effectcraft_project::render_queue::{
|
||||
AlphaMode, Channels, CurrentOrOff, EffectsMode, FrameSample, OutputFormat, OutputModule, RenderLog, RenderTiming, ResizeQuality, SwitchOverride, log_path,
|
||||
};
|
||||
use effectcraft_project::{BitDepth, Comp, Project};
|
||||
use effectcraft_raster::Image;
|
||||
use effectcraft_render::{Backend, LayerCache, RenderOpts, Renderer};
|
||||
@@ -272,6 +274,46 @@ pub(crate) struct Cx<'a> {
|
||||
/// Files written to an overflow folder.
|
||||
pub overflowed: Mutex<Vec<String>>,
|
||||
written: Mutex<Vec<String>>,
|
||||
/// Busy time per stage, for the log's timing line (#3713).
|
||||
phases: Phases,
|
||||
}
|
||||
|
||||
/// The stages of a job whose busy time is measured.
|
||||
#[derive(Clone, Copy)]
|
||||
pub(crate) enum Stage {
|
||||
/// Rendering frames (and, for formats that encode and write inside the frame loop, that too).
|
||||
Render,
|
||||
Encode,
|
||||
Write,
|
||||
Audio,
|
||||
/// An encoder that writes as it encodes (the GIF writer): the two are not apart.
|
||||
EncodeWrite,
|
||||
}
|
||||
|
||||
/// Busy time per [`Stage`] in nanoseconds. The stages overlap (the encoder works on one batch
|
||||
/// while the next renders), so each is its own total, not a share of the wall time.
|
||||
#[derive(Default)]
|
||||
struct Phases {
|
||||
nanos: [std::sync::atomic::AtomicU64; 5],
|
||||
/// Bit per stage that was timed: a stage a format doesn't have has no time, not zero.
|
||||
used: std::sync::atomic::AtomicU8,
|
||||
}
|
||||
|
||||
impl Phases {
|
||||
fn add(&self, stage: Stage, since: Instant) {
|
||||
self.used.fetch_or(1 << stage as u8, std::sync::atomic::Ordering::Relaxed);
|
||||
let n = u64::try_from(since.elapsed().as_nanos()).unwrap_or(u64::MAX);
|
||||
if let Some(slot) = self.nanos.get(stage as usize) {
|
||||
slot.fetch_add(n, std::sync::atomic::Ordering::Relaxed);
|
||||
}
|
||||
}
|
||||
fn seconds(&self, stage: Stage) -> f64 {
|
||||
self.nanos.get(stage as usize).map_or(0.0, |n| n.load(std::sync::atomic::Ordering::Relaxed) as f64 / 1e9)
|
||||
}
|
||||
/// The stage's busy time, or `None` when the format never timed it.
|
||||
fn measured(&self, stage: Stage) -> Option<f64> {
|
||||
(self.used.load(std::sync::atomic::Ordering::Relaxed) & (1 << stage as u8) != 0).then(|| self.seconds(stage))
|
||||
}
|
||||
}
|
||||
|
||||
/// A job's layer caches: its own, or those of the Render Queue run it belongs to.
|
||||
@@ -355,6 +397,7 @@ impl<'a> Cx<'a> {
|
||||
frame_times,
|
||||
overflowed: Mutex::new(vec![]),
|
||||
written: Mutex::new(vec![]),
|
||||
phases: Phases::default(),
|
||||
};
|
||||
if let Some(c) = cx.fixed_choice(std::env::var(RENDERER_ENV).ok().as_deref()) {
|
||||
cx.decide(c);
|
||||
@@ -362,6 +405,42 @@ impl<'a> Cx<'a> {
|
||||
cx
|
||||
}
|
||||
|
||||
/// Run `f` and add its time to `stage`'s busy time. Formats that encode and write outside
|
||||
/// the frame loop time those stages this way; a stage never timed is reported as measured
|
||||
/// together with rendering.
|
||||
pub(crate) fn timed<T>(&self, stage: Stage, f: impl FnOnce() -> T) -> T {
|
||||
let t = Instant::now();
|
||||
let out = f();
|
||||
self.add_time(stage, t);
|
||||
out
|
||||
}
|
||||
|
||||
/// [`Cx::timed`] when `on`; otherwise just run `f` (a stage the job doesn't have).
|
||||
pub(crate) fn timed_if<T>(&self, on: bool, stage: Stage, f: impl FnOnce() -> T) -> T {
|
||||
if on { self.timed(stage, f) } else { f() }
|
||||
}
|
||||
|
||||
/// Add the time since `since` to `stage`'s busy time (where a closure cannot wrap the work).
|
||||
pub(crate) fn add_time(&self, stage: Stage, since: Instant) {
|
||||
self.phases.add(stage, since);
|
||||
}
|
||||
|
||||
/// Where the job's time went, for the render log and the [`crate::Report`].
|
||||
pub(crate) fn timing(&self, wall: f64, frames: u64) -> RenderTiming {
|
||||
RenderTiming {
|
||||
wall_seconds: wall,
|
||||
render_seconds: self.phases.seconds(Stage::Render),
|
||||
encode_seconds: self.phases.measured(Stage::Encode),
|
||||
write_seconds: self.phases.measured(Stage::Write),
|
||||
encode_write_seconds: self.phases.measured(Stage::EncodeWrite),
|
||||
audio_seconds: self.phases.measured(Stage::Audio),
|
||||
frames,
|
||||
frames_per_second: if wall > 0.0 { frames as f64 / wall } else { 0.0 },
|
||||
renderer: self.choice().map_or_else(|| "none was needed".to_string(), |c| describe_choice(&c)),
|
||||
encoder: describe_encoder(self.job.output),
|
||||
}
|
||||
}
|
||||
|
||||
/// The project's compositor: the GPU's for GPU Acceleration with an accelerator.
|
||||
fn project_renderer(&self) -> crate::JobRenderer {
|
||||
if self.project.settings.gpu_acceleration && self.job.accel.is_some() { crate::JobRenderer::Gpu } else { crate::JobRenderer::Cpu }
|
||||
@@ -485,15 +564,19 @@ impl<'a> Cx<'a> {
|
||||
/// Output frames `ks`, each mapped by `f` (encoding): rendered in parallel batches, or one
|
||||
/// by one in passes when readbacks are deferred ([`Cx::deferred`]).
|
||||
pub async fn frames<T: Send>(&self, comp: &Comp, ks: Vec<u64>, f: impl Fn(u64, Image) -> T + Sync + Send) -> Vec<T> {
|
||||
if self.deferred() {
|
||||
let t = Instant::now();
|
||||
let out = if self.deferred() {
|
||||
let mut out = Vec::with_capacity(ks.len());
|
||||
for k in ks {
|
||||
let img = self.frame_async(comp, k).await;
|
||||
out.push(f(k, img));
|
||||
}
|
||||
return out;
|
||||
}
|
||||
self.render_frames(ks, |k, on| self.frame_on(comp, k, on), f)
|
||||
out
|
||||
} else {
|
||||
self.render_frames(ks, |k, on| self.frame_on(comp, k, on), f)
|
||||
};
|
||||
self.phases.add(Stage::Render, t);
|
||||
out
|
||||
}
|
||||
|
||||
/// `render` then `encode` over the frames `ks` on the job's compositor, results in `ks`
|
||||
@@ -807,14 +890,17 @@ impl<'a> Cx<'a> {
|
||||
fallback: impl Fn(u64, Image) -> T + Sync + Send,
|
||||
) -> Vec<T> {
|
||||
// As in `frames`: once the GPU has stopped for good, the rest render in parallel.
|
||||
self.render_frames(
|
||||
let t = Instant::now();
|
||||
let out = self.render_frames(
|
||||
ks,
|
||||
|k, on| self.yuv420_frame(comp, k, w, h, on).ok_or_else(|| self.frame_on(comp, k, on)),
|
||||
|k, r| match r {
|
||||
Ok(p) => planes(p),
|
||||
Err(img) => fallback(k, img),
|
||||
},
|
||||
)
|
||||
);
|
||||
self.phases.add(Stage::Render, t);
|
||||
out
|
||||
}
|
||||
|
||||
/// Output Module ▸ Crop, then Resize.
|
||||
@@ -927,7 +1013,7 @@ impl<'a> Cx<'a> {
|
||||
}
|
||||
|
||||
/// Write the render log next to the output, as the Log setting asks. Returns its path.
|
||||
pub fn write_log(&self, result: &Result<crate::Report, crate::ExportError>, seconds: f64) -> Option<String> {
|
||||
pub fn write_log(&self, result: &Result<crate::Report, crate::ExportError>, seconds: f64, timing: Option<&RenderTiming>) -> Option<String> {
|
||||
let level = self.job.options.log;
|
||||
// Errors Only: a log for failures (a user stop is not an error).
|
||||
if level == RenderLog::ErrorsOnly && matches!(result, Ok(_) | Err(crate::ExportError::Cancelled)) {
|
||||
@@ -946,6 +1032,13 @@ impl<'a> Cx<'a> {
|
||||
if let Some(c) = self.choice() {
|
||||
s.push_str(&format!("Renderer: {}\n", describe_choice(&c)));
|
||||
}
|
||||
if let Some(t) = timing {
|
||||
s.push_str(&format!(
|
||||
"Timing: {}
|
||||
",
|
||||
t.summary()
|
||||
));
|
||||
}
|
||||
if self.backend() == crate::JobRenderer::Gpu
|
||||
&& let Some((n, why)) = &*self.gpu_frames.lock().unwrap_or_else(std::sync::PoisonError::into_inner)
|
||||
{
|
||||
@@ -982,6 +1075,23 @@ impl<'a> Cx<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
/// The render log's account of the encoder: every encoder here is built in and runs on the
|
||||
/// CPU (no hardware encoder is used), with the codec settings of the Output Module.
|
||||
pub(crate) fn describe_encoder(om: &OutputModule) -> String {
|
||||
let rate = |om: &OutputModule| match om.codec.rate_control {
|
||||
effectcraft_project::render_queue::RateControlMode::Bitrate => format!("{} kbps", om.bitrate_kbps),
|
||||
effectcraft_project::render_queue::RateControlMode::Quality => format!("constant quality {}", om.codec.quality),
|
||||
};
|
||||
let settings = match om.format {
|
||||
OutputFormat::H264 => format!(", {} kbps", om.bitrate_kbps),
|
||||
OutputFormat::Hevc | OutputFormat::Av1 => format!(", profile {}, {}", om.codec.profile.label(), rate(om)),
|
||||
OutputFormat::ProRes => format!(", profile {}", om.prores_profile.label()),
|
||||
OutputFormat::WebM => format!(", {:?}{}", om.webm_codec, if om.webm_bitrate { format!(", {} kbps", om.bitrate_kbps) } else { String::new() }),
|
||||
_ => String::new(),
|
||||
};
|
||||
format!("{}{settings}, built-in software encoder (not a hardware encoder)", om.format.label())
|
||||
}
|
||||
|
||||
/// The render log's account of a job's compositor: which, why, and what was measured.
|
||||
pub(crate) fn describe_choice(c: &Choice) -> String {
|
||||
let name = match c.renderer {
|
||||
|
||||
@@ -17,8 +17,10 @@ use std::io::{Seek, SeekFrom, Write};
|
||||
use effectcraft_project::Comp;
|
||||
use effectcraft_project::render_queue::{AudioFormat, Channels};
|
||||
use effectcraft_time::{TICKS_PER_SECOND, Tick};
|
||||
use web_time::Instant;
|
||||
|
||||
use crate::encode::{mix, pcm_bytes};
|
||||
use crate::pipeline::Stage;
|
||||
use crate::{Cx, Report, Result, State, batch_size, io, wants_audio};
|
||||
|
||||
pub(crate) const OPUS_RATE: u32 = 48_000;
|
||||
@@ -263,6 +265,7 @@ pub(crate) async fn webm(job: &Cx<'_>, comp: &Comp, w: u32, h: u32, st: &mut Sta
|
||||
let pixels: Vec<Vec<u8>> =
|
||||
job.frames(comp, (i..end).collect(), |_, img| job.pixels(&img, comp, if alpha { Channels::Rgba } else { colour_channels }, w, h)).await;
|
||||
let mut frames: Vec<Frame> = Vec::with_capacity(pixels.len());
|
||||
let t = Instant::now();
|
||||
for (j, px) in pixels.iter().enumerate() {
|
||||
let (color, a) = rayon::join(
|
||||
|| {
|
||||
@@ -280,11 +283,14 @@ pub(crate) async fn webm(job: &Cx<'_>, comp: &Comp, w: u32, h: u32, st: &mut Sta
|
||||
frames.push(Frame { ms: frame_ms(k), track: 1, key: color.key, prev_ms: (k > 0).then(|| frame_ms(k - 1)), data: color.data, alpha: a });
|
||||
}
|
||||
drop(pixels);
|
||||
job.add_time(Stage::Encode, t);
|
||||
let t_end = if end >= total { span_end } else { job.settings.frame_time(comp, end) };
|
||||
audio_until(t_end, &mut frames, end >= total);
|
||||
job.timed_if(with_audio, Stage::Audio, || audio_until(t_end, &mut frames, end >= total));
|
||||
let t = Instant::now();
|
||||
let c = cluster(&mut frames);
|
||||
file.write_all(&c).map_err(io)?;
|
||||
seg_len += c.len() as u64;
|
||||
job.add_time(Stage::Write, t);
|
||||
st.advance(end - i)?;
|
||||
i = end;
|
||||
}
|
||||
@@ -305,7 +311,7 @@ pub(crate) async fn webm(job: &Cx<'_>, comp: &Comp, w: u32, h: u32, st: &mut Sta
|
||||
file.write_all(&size).map_err(io)?;
|
||||
file.seek(SeekFrom::End(0)).map_err(io)?;
|
||||
let bytes = file.finish()?;
|
||||
Ok(Report { path, frames: 0, width: w, height: h, seconds: 0.0, bytes, audio: with_audio, log: None, overflow: vec![] })
|
||||
Ok(Report { path, frames: 0, width: w, height: h, seconds: 0.0, bytes, audio: with_audio, log: None, overflow: vec![], timing: Default::default() })
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- audio-only outputs
|
||||
@@ -349,7 +355,7 @@ pub(crate) fn audio_file(job: &Cx, comp: &Comp, aiff: bool, st: &mut State) -> R
|
||||
let sample = start + done as i64;
|
||||
let t = Tick::from_units(sample, i64::from(sr));
|
||||
let t = if t.to_units_floor(i64::from(sr)) < sample { Tick(t.0.saturating_add(1)) } else { t };
|
||||
pcm.extend(pcm_bytes(&mix(job, t, k, sr), fmt, aiff));
|
||||
pcm.extend(job.timed(Stage::Audio, || pcm_bytes(&mix(job, t, k, sr), fmt, aiff)));
|
||||
done += k;
|
||||
let now = (done as u64 * total_frames / n.max(1) as u64).min(total_frames);
|
||||
if now > reported && st.total > 0 {
|
||||
@@ -421,11 +427,13 @@ pub(crate) fn audio_file(job: &Cx, comp: &Comp, aiff: bool, st: &mut State) -> R
|
||||
out.push(0);
|
||||
}
|
||||
}
|
||||
let t = Instant::now();
|
||||
let path = job.place(job.path, out.len() as u64);
|
||||
let mut file = job.create(&path)?;
|
||||
file.write_all(&out).map_err(io)?;
|
||||
let bytes = file.finish()?;
|
||||
Ok(Report { path, frames: 0, width: 0, height: 0, seconds: 0.0, bytes, audio: true, log: None, overflow: vec![] })
|
||||
job.add_time(Stage::Write, t);
|
||||
Ok(Report { path, frames: 0, width: 0, height: 0, seconds: 0.0, bytes, audio: true, log: None, overflow: vec![], timing: Default::default() })
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -12,6 +12,7 @@ use effectcraft_time::{TICKS_PER_SECOND, Tick};
|
||||
|
||||
use crate::encode::VideoEncoder;
|
||||
use crate::encode::mix;
|
||||
use crate::pipeline::Stage;
|
||||
use crate::webm::{CLUSTER, EBML, INFO, OPUS_RATE, SEGMENT, TRACK_ENTRY, TRACKS, el, el_float, el_str, el_uint, id_bytes, opus_encoder, vint};
|
||||
use crate::{Cx, Report, Result, State, batch_size, io, wants_audio};
|
||||
|
||||
@@ -154,13 +155,13 @@ pub(crate) async fn webm_av1(job: &Cx<'_>, comp: &Comp, w: u32, h: u32, st: &mut
|
||||
let frames: Vec<Vec<u8>> = job.frames(comp, (i..end).collect(), |_, img| job.pixels(&img, comp, channels, w, h)).await;
|
||||
for (j, px) in frames.iter().enumerate() {
|
||||
let k = i + j as u64;
|
||||
for p in venc.encode(px, k)? {
|
||||
for p in job.timed(Stage::Encode, || venc.encode(px, k))? {
|
||||
blocks.push(Block { ms: frame_ms(k), track: 1, key: p.key, data: p.data });
|
||||
}
|
||||
}
|
||||
let t_end = if end >= total { span_end } else { job.settings.frame_time(comp, end) };
|
||||
audio_until(t_end, &mut blocks, end >= total);
|
||||
flush_blocks(&mut blocks, &mut file, &mut seg_len)?;
|
||||
job.timed_if(with_audio, Stage::Audio, || audio_until(t_end, &mut blocks, end >= total));
|
||||
job.timed(Stage::Write, || flush_blocks(&mut blocks, &mut file, &mut seg_len))?;
|
||||
st.advance(end - i)?;
|
||||
i = end;
|
||||
}
|
||||
@@ -175,5 +176,5 @@ pub(crate) async fn webm_av1(job: &Cx<'_>, comp: &Comp, w: u32, h: u32, st: &mut
|
||||
file.write_all(&size).map_err(io)?;
|
||||
file.seek(SeekFrom::End(0)).map_err(io)?;
|
||||
let bytes = file.finish()?;
|
||||
Ok(Report { path, frames: 0, width: w, height: h, seconds: 0.0, bytes, audio: with_audio, log: None, overflow: vec![] })
|
||||
Ok(Report { path, frames: 0, width: w, height: h, seconds: 0.0, bytes, audio: with_audio, log: None, overflow: vec![], timing: Default::default() })
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
//! The summary line of an export (#3713): where the time went and what ran the job.
|
||||
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use effectcraft_color::Label;
|
||||
use effectcraft_export::render_queue::{OutputFormat, OutputModule, RenderLog, RenderSettings, TimeSpan};
|
||||
use effectcraft_export::{Job, JobOptions, Sink, export};
|
||||
use effectcraft_project::{Comp, ItemId, ItemKind, LayerSource, Project, Solid, build};
|
||||
use effectcraft_render::NoFootage;
|
||||
use effectcraft_time::{FrameRate, Tick};
|
||||
|
||||
fn project() -> (Project, ItemId) {
|
||||
let mut p = Project::default();
|
||||
let comp = Comp::new(64, 48, FrameRate::new(30, 1), Tick::from_seconds_f64(1.0));
|
||||
let sid = p.add_item("Solid", Label::Red, None, ItemKind::Solid(Solid { color: [0.9, 0.5, 0.1], width: 64, height: 48, pixel_aspect: 1.0 }));
|
||||
let layer = build::layer(&mut p, &comp, "Solid", LayerSource::Solid { item: sid }, (64, 48), None);
|
||||
let mut comp = comp;
|
||||
comp.layers = vec![layer].into();
|
||||
let cid = p.add_item("Comp 1", Label::Sandstone, None, ItemKind::Comp(comp.into()));
|
||||
(p, cid)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_movie_export_reports_where_the_time_went() {
|
||||
let (p, cid) = project();
|
||||
let settings = RenderSettings { time_span: TimeSpan::LengthOfComp, ..Default::default() };
|
||||
let om = OutputModule::for_format(OutputFormat::H264);
|
||||
let files: Arc<Mutex<Vec<(String, Vec<u8>)>>> = Arc::default();
|
||||
let sink_files = files.clone();
|
||||
let sink: &Sink = &move |path: &str, data: Vec<u8>| sink_files.lock().unwrap().push((path.to_string(), data));
|
||||
let job = Job {
|
||||
project: &p,
|
||||
footage: &NoFootage,
|
||||
expr: None,
|
||||
accel: None,
|
||||
comp: cid,
|
||||
settings: &settings,
|
||||
output: &om,
|
||||
path: "/out/timing.mp4",
|
||||
sink: Some(sink),
|
||||
options: JobOptions { log: RenderLog::PlusSettings, label: "#1 Comp 1".into(), ..Default::default() },
|
||||
nested_switches: true,
|
||||
};
|
||||
let r = export(&job, &mut |_| true).expect("export");
|
||||
let t = &r.timing;
|
||||
assert_eq!(t.frames, 30);
|
||||
assert!(t.wall_seconds > 0.0);
|
||||
// The movie formats time encoding and writing apart from rendering.
|
||||
let (encode, write) = (t.encode_seconds.expect("encode time"), t.write_seconds.expect("write time"));
|
||||
for (name, secs) in [("render", t.render_seconds), ("encode", encode), ("write", write)] {
|
||||
assert!(secs >= 0.0 && secs <= t.wall_seconds, "{name} {secs} s of {} s wall", t.wall_seconds);
|
||||
}
|
||||
assert!(t.render_seconds > 0.0 && encode > 0.0, "{t:?}");
|
||||
assert_eq!(t.audio_seconds, None);
|
||||
assert!((t.frames_per_second - 30.0 / t.wall_seconds).abs() < 1e-9);
|
||||
assert!(t.renderer.starts_with("Software Rendering"), "{}", t.renderer);
|
||||
assert!(t.encoder.contains("H.264") && t.encoder.contains("software"), "{}", t.encoder);
|
||||
|
||||
let line = t.summary();
|
||||
for part in
|
||||
["export took", "30 frames", "frames/s", "overlap", "rendering frames", "encoder", "writing output", "Compositor: Software Rendering", "Encoder: H.264"]
|
||||
{
|
||||
assert!(line.contains(part), "{part:?} missing from {line}");
|
||||
}
|
||||
// The render log carries the same line.
|
||||
let files = files.lock().unwrap();
|
||||
let log = files.iter().find(|(path, _)| path.ends_with(".txt")).map(|(_, d)| String::from_utf8_lossy(d).into_owned()).expect("render log");
|
||||
assert!(log.contains(&format!("Timing: {line}")), "{log}");
|
||||
}
|
||||
|
||||
fn job_of<'a>(p: &'a Project, cid: ItemId, settings: &'a RenderSettings, om: &'a OutputModule, path: &'a str, sink: &'a Sink) -> Job<'a> {
|
||||
Job {
|
||||
project: p,
|
||||
footage: &NoFootage,
|
||||
expr: None,
|
||||
accel: None,
|
||||
comp: cid,
|
||||
settings,
|
||||
output: om,
|
||||
path,
|
||||
sink: Some(sink),
|
||||
options: Default::default(),
|
||||
nested_switches: true,
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_image_sequence_says_the_stages_are_measured_together() {
|
||||
let (p, cid) = project();
|
||||
let settings = RenderSettings { time_span: TimeSpan::LengthOfComp, ..Default::default() };
|
||||
let om = OutputModule::for_format(OutputFormat::PngSequence);
|
||||
let sink: &Sink = &|_: &str, _: Vec<u8>| {};
|
||||
let r = export(&job_of(&p, cid, &settings, &om, "/out/timing_[#####].png", sink), &mut |_| true).expect("export");
|
||||
let t = &r.timing;
|
||||
assert_eq!((t.encode_seconds, t.write_seconds, t.encode_write_seconds), (None, None, None));
|
||||
assert!(t.render_seconds <= t.wall_seconds);
|
||||
assert!(t.summary().contains("rendering, encoding and writing measured together"), "{}", t.summary());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn gif_and_webm_time_the_stages_they_have() {
|
||||
let (p, cid) = project();
|
||||
let settings = RenderSettings { time_span: TimeSpan::LengthOfComp, ..Default::default() };
|
||||
let sink: &Sink = &|_: &str, _: Vec<u8>| {};
|
||||
let gif = OutputModule::for_format(OutputFormat::Gif);
|
||||
let t = export(&job_of(&p, cid, &settings, &gif, "/out/timing.gif", sink), &mut |_| true).expect("gif").timing;
|
||||
assert_eq!((t.encode_seconds, t.write_seconds), (None, None));
|
||||
let both = t.encode_write_seconds.expect("encode and write time");
|
||||
assert!(both >= 0.0 && both <= t.wall_seconds && t.render_seconds <= t.wall_seconds);
|
||||
assert!(t.summary().contains("encoding and writing output measured together"), "{}", t.summary());
|
||||
|
||||
let webm = OutputModule::for_format(OutputFormat::WebM);
|
||||
let t = export(&job_of(&p, cid, &settings, &webm, "/out/timing.webm", sink), &mut |_| true).expect("webm").timing;
|
||||
let (e, w) = (t.encode_seconds.expect("encode"), t.write_seconds.expect("write"));
|
||||
assert!(e <= t.wall_seconds && w <= t.wall_seconds && t.render_seconds <= t.wall_seconds, "{t:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_stopped_export_has_a_summary_without_a_frame_count() {
|
||||
let t = effectcraft_export::render_queue::RenderTiming {
|
||||
wall_seconds: 2.0,
|
||||
render_seconds: 1.5,
|
||||
renderer: "Software Rendering (x)".into(),
|
||||
encoder: "H.264".into(),
|
||||
..Default::default()
|
||||
};
|
||||
let line = t.summary_of_unfinished("stopped");
|
||||
assert!(line.starts_with("export stopped after 2.00 s. Busy time per stage"), "{line}");
|
||||
assert!(!line.contains("frames/s"), "{line}");
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
mod audio_sample_positions;
|
||||
mod av1_encoder;
|
||||
mod banding;
|
||||
mod export_timing;
|
||||
mod exr_scene_linear;
|
||||
mod h264_gpu_yuv;
|
||||
mod hevc_av1_roundtrip;
|
||||
|
||||
@@ -83,6 +83,7 @@ impl Exporter for FileExporter {
|
||||
audio: r.audio,
|
||||
log: r.log,
|
||||
overflow: r.overflow,
|
||||
timing: Some(r.timing),
|
||||
}),
|
||||
Err(effectcraft_export::ExportError::Cancelled) => Err(effectcraft_engine::render_queue::CANCELLED.into()),
|
||||
Err(e) => Err(e.to_string()),
|
||||
|
||||
@@ -1473,6 +1473,76 @@ impl RenderStatus {
|
||||
}
|
||||
}
|
||||
|
||||
/// Where one export's time went, and what it ran on (the render log's summary line, #3713).
|
||||
/// The stages overlap (the encoder works on one batch while the next renders), so the
|
||||
/// `*_seconds` are each stage's busy time and not a sum; none of them is more than `wall_seconds`.
|
||||
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(default)]
|
||||
pub struct RenderTiming {
|
||||
/// The whole job, start to end.
|
||||
pub wall_seconds: f64,
|
||||
/// Time rendering frames (the compositor, including the conversion to the encoder's pixels).
|
||||
/// For formats that encode and write inside the frame loop (image sequences) it also holds
|
||||
/// the encoding and writing: `encode_seconds` and `write_seconds` are `None`.
|
||||
pub render_seconds: f64,
|
||||
/// Time in the video encoder (`None`: not measured apart from rendering).
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub encode_seconds: Option<f64>,
|
||||
/// Time writing and muxing the output file (`None`: not measured apart from rendering).
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub write_seconds: Option<f64>,
|
||||
/// Time in an encoder that writes as it encodes (GIF): encoding and writing are not apart.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub encode_write_seconds: Option<f64>,
|
||||
/// Time mixing and encoding the audio track (`None`: no separate audio stage).
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub audio_seconds: Option<f64>,
|
||||
pub frames: u64,
|
||||
/// Frames per second of wall time over the whole job.
|
||||
pub frames_per_second: f64,
|
||||
/// The compositor and why it was used.
|
||||
pub renderer: String,
|
||||
/// The encoder: name, software or hardware, codec settings.
|
||||
pub encoder: String,
|
||||
}
|
||||
|
||||
impl RenderTiming {
|
||||
/// The one-line summary for the render log.
|
||||
pub fn summary(&self) -> String {
|
||||
let head = format!("export took {:.2} s for {} frames ({:.2} frames/s)", self.wall_seconds, self.frames, self.frames_per_second);
|
||||
self.line(&head)
|
||||
}
|
||||
|
||||
/// The summary of a job that was stopped or failed `how` (the frames done are not counted).
|
||||
pub fn summary_of_unfinished(&self, how: &str) -> String {
|
||||
self.line(&format!("export {how} after {:.2} s", self.wall_seconds))
|
||||
}
|
||||
|
||||
fn line(&self, head: &str) -> String {
|
||||
let (r, mut s) = (self.render_seconds, String::new());
|
||||
if self.encode_seconds.is_none() && self.write_seconds.is_none() && self.encode_write_seconds.is_none() {
|
||||
s.push_str(&format!("rendering, encoding and writing measured together {r:.2} s"));
|
||||
} else if self.encode_write_seconds.is_some() {
|
||||
// The GIF palette is quantised on the render threads, so it counts as rendering.
|
||||
s.push_str(&format!("rendering frames (GIF: including palette quantizing) {r:.2} s"));
|
||||
} else if r > 0.0 {
|
||||
s.push_str(&format!("rendering frames {r:.2} s"));
|
||||
}
|
||||
for (label, v) in [
|
||||
("encoder", self.encode_seconds),
|
||||
("writing output", self.write_seconds),
|
||||
("encoding and writing output measured together", self.encode_write_seconds),
|
||||
("audio", self.audio_seconds),
|
||||
] {
|
||||
if let Some(v) = v {
|
||||
s.push_str(&format!("{}{label} {v:.2} s", if s.is_empty() { "" } else { ", " }));
|
||||
}
|
||||
}
|
||||
let stages = s;
|
||||
format!("{head}. Busy time per stage (the stages overlap, so this is not a sum): {stages}. Compositor: {}. Encoder: {}", self.renderer, self.encoder)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct RenderQueueItem {
|
||||
/// Stable id (unique within the queue).
|
||||
@@ -1495,6 +1565,9 @@ pub struct RenderQueueItem {
|
||||
/// Resolved path of the last render (first file for sequences).
|
||||
#[serde(default)]
|
||||
pub last_output: Option<String>,
|
||||
/// Where the last render's time went (see [`RenderTiming`]).
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub last_timing: Option<RenderTiming>,
|
||||
/// Further Output Modules (Composition ▸ Add Output Module): the same frames are encoded
|
||||
/// once per module.
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
@@ -1624,6 +1697,7 @@ impl RenderQueueItem {
|
||||
started: None,
|
||||
render_time: None,
|
||||
last_output: None,
|
||||
last_timing: None,
|
||||
extra_outputs: vec![],
|
||||
post_render: PostRenderAction::None,
|
||||
log: RenderLog::ErrorsOnly,
|
||||
|
||||
@@ -114,6 +114,11 @@ Commands (CLI, MCP, control channel):
|
||||
names it and why). `EFFECTCRAFT_RQ_RENDERER` set to `gpu` or `cpu` skips it and renders on
|
||||
that compositor; `auto` (the default) measures. A queue item's later output modules reuse its
|
||||
first one's choice, and Software Rendering projects always render on the CPU.
|
||||
When a job ends, the render log gets one `Timing:` line (and the log target `effectcraft_export`
|
||||
the same line): the wall time, the busy time of rendering, the encoder and writing the file
|
||||
(the stages overlap, so they are not a sum), the compositor and why, the encoder and its
|
||||
settings, and frames per second ([#3713](https://github.com/storytold/effectcraft/issues/3713)).
|
||||
`effectcraft-cli render --json` returns it as `timing` and `timingSummary`.
|
||||
- `threeD.defaultRenderer`: Default 3D Renderer
|
||||
- `labels.N.name` / `labels.N.color`: the 16 label names and colours, used by the Label menu,
|
||||
the timeline, project panel, render queue and viewer handles
|
||||
|
||||
Reference in new issue
Block a user