|
| 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 | +} |
0 commit comments