[go: up one dir, main page]

Skip to content

Commit

Permalink
Merge pull request #5 from polyesterswing/dev
Browse files Browse the repository at this point in the history
feat: get filename through command-line
  • Loading branch information
isinghdivyanshu authored Aug 17, 2024
2 parents 9806fcc + e2b8a28 commit d199374
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ use crossterm::{
execute,
terminal::{disable_raw_mode, enable_raw_mode, Clear, ClearType},
};

use std::env;
use std::io;

fn map_range(from_range: (i32, i32), to_range: (i32, i32), s: i32) -> i32 {
Expand Down Expand Up @@ -46,11 +48,6 @@ fn find_colors(frame: &Mat, gray: &Mat, table: &str, table_len: usize) -> Result
}

fn main() -> Result<()> {
enable_raw_mode().unwrap();

let mut stdout = io::stdout();

execute!(stdout, terminal::EnterAlternateScreen).unwrap();

let mut is_paused = false;
let mut time_multiplier = 1.0;
Expand All @@ -61,16 +58,30 @@ fn main() -> Result<()> {

let term_size = crossterm::terminal::size().unwrap();

let mut cam = videoio::VideoCapture::from_file("baby-shark.webm", videoio::CAP_ANY)?;
let args: Vec<String> = env::args().collect();

if args.len() < 2 {
println!("Usage: {} <video file>", args[0]);
return Ok(());
}

let video_file = &args[1];

let mut cam = videoio::VideoCapture::from_file(video_file, videoio::CAP_ANY)?;

if !cam.is_opened()? {
panic!("Unable to open video file");
println!("Unable to open video file: {}", video_file);
return Ok(());
}

let fps = cam.get(videoio::CAP_PROP_FPS)?;
// time b/w each frame
let frame_delay = time::Duration::from_millis((1000.0 / fps) as u64);

enable_raw_mode().unwrap();
let mut stdout = io::stdout();
execute!(stdout, terminal::EnterAlternateScreen).unwrap();

let (tx, rx) = mpsc::sync_channel(50);
execute!(stdout, Hide).unwrap();

Expand Down

0 comments on commit d199374

Please sign in to comment.