#886: say why footage the decoders can't read shows no picture
Problem: a movie whose profile the software decoders lack (H.264 High 4:2:2 / 10-bit) probes fine, then every frame read fails; MediaPool logged the error per frame and returned None, so the layer rendered black with no sign why in the viewer, Project panel or for agents. Fix: MediaPool records the reason once per file (codec from the probe plus the decoder's text without error wrappers; I/O errors stay with missing-footage handling), logs it once, and exposes it through the new FootageSource::problem. The Composition viewer shows it on the affected layer, the Project panel marks the item with a warning whose tooltip is the reason, and project.summary / footage.info carry a "problem" field. Cleared when the file is forgotten; only set when decoding really failed, so a hardware decoder that handles the file shows nothing. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
67434e9038
commit
74b95b0a9d
@@ -441,7 +441,21 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
actions.push(("file.useProxy".into(), json!({"item": id.0})));
|
||||
}
|
||||
}
|
||||
let name_clip = Rect::from_min_max(pos2(x0 + 30.0, r.min.y), pos2(r.min.x + name_w + 4.0, r.max.y)).intersect(list);
|
||||
// Footage that can't be decoded (no decoder for its codec / profile): a warning marker
|
||||
// at the end of the name cell, the reason on hover.
|
||||
let problem = match &it.kind {
|
||||
ItemKind::Footage(f) => app.session.footage.problem(f),
|
||||
_ => None,
|
||||
};
|
||||
let name_clip =
|
||||
Rect::from_min_max(pos2(x0 + 30.0, r.min.y), pos2(r.min.x + name_w + 4.0 - if problem.is_some() { 16.0 } else { 0.0 }, r.max.y)).intersect(list);
|
||||
if let Some(why) = &problem {
|
||||
let m = Rect::from_center_size(pos2(r.min.x + name_w - 8.0, r.center().y), vec2(13.0, 12.0));
|
||||
lp.add(egui::Shape::convex_polygon(vec![m.center_top(), m.right_bottom(), m.left_bottom()], t.warning, Stroke::NONE));
|
||||
lp.text(m.center() + vec2(0.0, 1.5), Align2::CENTER_CENTER, "!", Tokens::semibold(9.0), Color32::BLACK);
|
||||
ui.interact(m.expand(2.0).intersect(list), egui::Id::new(("pproblem", id.0)), Sense::hover()).on_hover_text(why.as_str());
|
||||
app.auto.add(&format!("project.item.{}.problem", id.0), m, why);
|
||||
}
|
||||
let name_rect = Rect::from_min_max(pos2(x0 + 28.0, r.min.y + 2.0), pos2(r.min.x + name_w + 2.0, r.max.y - 2.0));
|
||||
// Inline edits (rename / comment).
|
||||
let cell_edit = |app: &mut EffectcraftApp, ui: &mut egui::Ui, actions: &mut Vec<(String, serde_json::Value)>, field: &str, cell: Rect| -> bool {
|
||||
|
||||
@@ -1045,6 +1045,30 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
app.auto.add("viewer.warpBanner", r, &text);
|
||||
}
|
||||
|
||||
// Footage that can't be decoded (no decoder for its codec / profile): say why on the layer
|
||||
// instead of leaving a black picture.
|
||||
let mut notices = 0;
|
||||
for layer in comp.layers.iter().filter(|l| l.is_active_at(time) && l.switches.video) {
|
||||
let effectcraft_engine::project::LayerSource::Footage { item } = &layer.source else { continue };
|
||||
let Some(effectcraft_engine::project::ItemKind::Footage(f)) = app.session.project.item(*item).map(|i| &i.kind) else { continue };
|
||||
let Some(why) = app.session.footage.problem(f) else { continue };
|
||||
if notices >= 3 {
|
||||
break;
|
||||
}
|
||||
let (m, _) = l2c(&ectx, layer);
|
||||
let (w, h) = effectcraft_engine::render::source_size(&app.session.project, layer);
|
||||
let c = m.apply(effectcraft_engine::geom::vec2(w as f64 / 2.0, h as f64 / 2.0));
|
||||
let at = map.to_screen([c.x, c.y]);
|
||||
let text = format!("{}: {}", layer.name, why);
|
||||
let galley = painter.layout(text.clone(), Tokens::medium(12.0), Color32::WHITE, (map.area.width() - 40.0).clamp(80.0, 420.0));
|
||||
let r = Rect::from_center_size(at + vec2(0.0, notices as f32 * 4.0), galley.size() + vec2(24.0, 16.0)).intersect(map.area);
|
||||
painter.rect_filled(r, 3.0, Color32::from_rgba_unmultiplied(0x4a, 0x1a, 0x14, 0xe6));
|
||||
painter.rect_stroke(r, 3.0, Stroke::new(1.0, t.warning), StrokeKind::Inside);
|
||||
painter.galley(pos2(r.min.x + 12.0, r.center().y - galley.size().y / 2.0), galley, Color32::WHITE);
|
||||
app.auto.add(&format!("viewer.footageProblem.{}", layer.id.0), r, &text);
|
||||
notices += 1;
|
||||
}
|
||||
|
||||
// Free transform box of a path (double-click a path with the Selection tool).
|
||||
let ft = ov::draw_free_transform(app, &ctx, &painter, &map, &paths);
|
||||
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
//! Footage whose codec the decoders lack says so: a warning marker in the Project panel and a
|
||||
//! notice on the layer in the Composition viewer, instead of a black picture with no reason.
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use effectcraft_engine::Session;
|
||||
use effectcraft_engine::project::{Footage, FootageKind, ItemId, ItemKind};
|
||||
use effectcraft_engine::render::FootageSource;
|
||||
use effectcraft_render::Image;
|
||||
use effectcraft_time::Tick;
|
||||
use effectcraft_ui_egui::EffectcraftApp;
|
||||
use egui_kittest::Harness;
|
||||
use serde_json::json;
|
||||
|
||||
const WHY: &str = "H.264 (High 4:2:2) isn't supported by the built-in decoder: chroma_format_idc 2 (only 4:2:0 is implemented)";
|
||||
|
||||
/// A source that decodes nothing and, for `broken` movies, says why.
|
||||
struct Stub(bool);
|
||||
|
||||
impl FootageSource for Stub {
|
||||
fn frame(&self, _: ItemId, _: &Footage, _: Tick) -> Option<Arc<Image>> {
|
||||
None
|
||||
}
|
||||
fn problem(&self, _: &Footage) -> Option<String> {
|
||||
self.0.then(|| WHY.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
fn harness(broken: bool) -> (Harness<'static, EffectcraftApp>, ItemId) {
|
||||
let mut s = Session { footage: Arc::new(Stub(broken)), ..Default::default() };
|
||||
s.execute("comp.new", json!({"name": "Main", "width": 320, "height": 180, "duration": 4})).unwrap();
|
||||
let footage = Footage {
|
||||
kind: FootageKind::Video,
|
||||
path: "clip.mp4".into(),
|
||||
width: 64,
|
||||
height: 36,
|
||||
has_video: true,
|
||||
duration: Tick::from_seconds_f64(2.0),
|
||||
..Default::default()
|
||||
};
|
||||
let clip = std::sync::Arc::make_mut(&mut s.project).add_item("Clip", Default::default(), None, ItemKind::Footage(footage));
|
||||
s.execute("layer.addItem", json!({"item": clip.0})).unwrap();
|
||||
s.execute("project.select", json!({"items": []})).unwrap();
|
||||
let mut h = Harness::builder().with_size(egui::vec2(1600.0, 1000.0)).build_eframe(|_| EffectcraftApp::new(s));
|
||||
h.run_steps(4);
|
||||
(h, clip)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn undecodable_footage_is_marked_in_the_project_panel_and_the_viewer() {
|
||||
let (h, clip) = harness(true);
|
||||
let marker = h.state().auto.find(&format!("project.item.{}.problem", clip.0)).expect("a warning on the footage item").clone();
|
||||
assert!(marker.label.contains("4:2:2"), "{marker:?}");
|
||||
let notice = h.state().auto.query("viewer.footageProblem.").first().copied().expect("a notice in the viewer").clone();
|
||||
assert!(notice.label.contains(WHY), "{notice:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn readable_footage_has_no_notice() {
|
||||
let (h, clip) = harness(false);
|
||||
assert!(h.state().auto.find(&format!("project.item.{}.problem", clip.0)).is_none());
|
||||
assert!(h.state().auto.query("viewer.footageProblem.").is_empty());
|
||||
}
|
||||
Reference in New Issue
Block a user