Skip to content

Commit 4d04a52

Browse files
committed
feat: enhance codebase
1 parent 45c4448 commit 4d04a52

33 files changed

+3438
-3421
lines changed

src/commands/info.rs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
use crate::error::Result;
2+
use crate::load_scenario;
3+
use crate::schema;
4+
use std::path::PathBuf;
5+
6+
pub fn cmd_info(input: &PathBuf) -> Result<()> {
7+
let scenario = load_scenario(input)?;
8+
let fps = scenario.video.fps;
9+
let all_scenes: Vec<_> = scenario.all_scenes().collect();
10+
let total_duration: f64 = all_scenes.iter().map(|s| s.duration).sum();
11+
let total_frames: u32 = all_scenes
12+
.iter()
13+
.map(|s| (s.duration * fps as f64).round() as u32)
14+
.sum();
15+
16+
let total_layers: usize = all_scenes.iter().map(|s| s.children.len()).sum();
17+
18+
println!("File: {}", input.display());
19+
println!("Resolution: {}x{}", scenario.video.width, scenario.video.height);
20+
println!("FPS: {}", fps);
21+
println!("Duration: {:.1}s ({} frames)", total_duration, total_frames);
22+
println!("Views: {}", scenario.views.len());
23+
println!("Scenes: {}", all_scenes.len());
24+
println!("Total layers: {}", total_layers);
25+
println!("Audio tracks: {}", scenario.audio.len());
26+
27+
for (vi, view) in scenario.views.iter().enumerate() {
28+
let vtype = match view.view_type {
29+
schema::ViewType::Slide => "Slide",
30+
schema::ViewType::World => "World",
31+
};
32+
println!(" View {}: {} ({} scenes)", vi + 1, vtype, view.scenes.len());
33+
for (si, scene) in view.scenes.iter().enumerate() {
34+
let scene_frames = (scene.duration * fps as f64).round() as u32;
35+
println!(
36+
" Scene {}: {:.1}s ({} frames, {} layers{})",
37+
si + 1,
38+
scene.duration,
39+
scene_frames,
40+
scene.children.len(),
41+
scene
42+
.transition
43+
.as_ref()
44+
.map(|t| format!(", transition: {:?} {:.1}s", t.transition_type, t.duration))
45+
.unwrap_or_default()
46+
);
47+
}
48+
}
49+
50+
Ok(())
51+
}

src/commands/mod.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
mod info;
2+
mod render;
3+
mod schema;
4+
mod still;
5+
mod validate;
6+
7+
pub use info::cmd_info;
8+
pub use render::{cmd_render, cmd_watch};
9+
pub use schema::cmd_schema;
10+
pub use still::cmd_still;
11+
pub use validate::cmd_validate;

0 commit comments

Comments
 (0)