Initial release: friendly TUI for FFmpeg
File browser, stackable edits (trim, resize, crop, rotate, speed, color, effects, fps, compress, convert, audio) with a live preview of the generated ffmpeg command, progress bar with cancel, audio-aware edit menus, and Catppuccin Macchiato theme.
This commit is contained in:
+58
@@ -0,0 +1,58 @@
|
||||
mod app;
|
||||
mod ffmpeg;
|
||||
mod ops;
|
||||
mod ui;
|
||||
|
||||
use std::process::Command;
|
||||
use std::time::Duration;
|
||||
|
||||
use anyhow::{bail, Result};
|
||||
use ratatui::crossterm::event::{self, Event, KeyEventKind};
|
||||
use ratatui::DefaultTerminal;
|
||||
|
||||
use app::App;
|
||||
|
||||
fn main() -> Result<()> {
|
||||
if let Some(arg) = std::env::args().nth(1) {
|
||||
match arg.as_str() {
|
||||
"--version" | "-V" => {
|
||||
println!("lazyff {}", env!("CARGO_PKG_VERSION"));
|
||||
return Ok(());
|
||||
}
|
||||
_ => {
|
||||
println!("lazyff {} — a friendly TUI for FFmpeg", env!("CARGO_PKG_VERSION"));
|
||||
println!("Usage: lazyff (opens a file browser in the current directory)");
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for bin in ["ffmpeg", "ffprobe"] {
|
||||
if Command::new(bin).arg("-version").output().is_err() {
|
||||
bail!("{bin} was not found on your PATH. Please install FFmpeg first.");
|
||||
}
|
||||
}
|
||||
|
||||
let mut terminal = ratatui::init();
|
||||
let result = run(&mut terminal);
|
||||
ratatui::restore();
|
||||
result
|
||||
}
|
||||
|
||||
fn run(terminal: &mut DefaultTerminal) -> Result<()> {
|
||||
let mut app = App::new()?;
|
||||
loop {
|
||||
app.poll_run_messages();
|
||||
terminal.draw(|f| ui::draw(f, &mut app))?;
|
||||
if event::poll(Duration::from_millis(100))? {
|
||||
if let Event::Key(key) = event::read()? {
|
||||
if key.kind == KeyEventKind::Press {
|
||||
app.on_key(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
if app.should_quit {
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user