commit a1b5dd9ce82f21d492621d0868aaefd048cf5a73 Author: CrispyPin Date: Sun Apr 14 16:39:42 2024 +0200 init diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4ae9e8b --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +/target +out/* + diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..287020a --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "bad-apple-mpv" +version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..b21c983 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "bad-apple-mpv" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/bad_apple.webm b/bad_apple.webm new file mode 100644 index 0000000..3808ff9 Binary files /dev/null and b/bad_apple.webm differ diff --git a/bad_apple_audio.webm b/bad_apple_audio.webm new file mode 100644 index 0000000..4c8f35a Binary files /dev/null and b/bad_apple_audio.webm differ diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 0000000..218e203 --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1 @@ +hard_tabs = true diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..dff6fdd --- /dev/null +++ b/src/main.rs @@ -0,0 +1,66 @@ +use std::{env, process::Command, thread, time::Duration}; + +// const WIDTH: u32 = 7; +// const HEIGHT: u32 = 7; +const WIDTH: u32 = 14; +const HEIGHT: u32 = 13; +const _SIZE: u32 = WIDTH * HEIGHT; +const SCALE: u32 = 2; // resolution of chunks +const OFFSET: f32 = 0.1; // time offset for starting + +fn main() { + let args: Vec<_> = env::args().collect(); + if args.contains(&"gen".into()) { + generate(); + } else { + launch(); + } +} + +fn generate() { + for x in 0..WIDTH { + for y in 0..HEIGHT { + let name = format!("out/{x:02}_{y:02}.mp4"); + let index = (WIDTH - x) + (HEIGHT - y) * WIDTH; + let offset = index as f32 * OFFSET; + // println!("{name}"); + + // if PathBuf::from(&name).exists() { + // continue; + // } + Command::new("ffmpeg") + .arg("-i") + .arg("bad_apple.webm") + .arg("-ss") + .arg(format!("{:.1}", offset)) + .arg("-filter_complex") + .arg(dbg!(format!( + "[0:v]scale={}:{}[SC];[SC]crop={SCALE}:{SCALE}:{}:{}", + WIDTH * SCALE, + HEIGHT * SCALE, + x * SCALE, + y * SCALE + ))) + .arg("-an") + .arg("-y") + .arg(&name) + .spawn() + .unwrap(); + } + } +} + +fn launch() { + thread::sleep(Duration::from_secs(2)); + Command::new("mpv") + .arg(format!("bad_apple_audio.webm")) + .spawn() + .unwrap(); + for y in (0..HEIGHT).rev() { + for x in (0..WIDTH).rev() { + let name = format!("out/{x:02}_{y:02}.mp4"); + Command::new("mpv").arg(name).spawn().unwrap(); + thread::sleep(Duration::from_millis((1000.0 * OFFSET) as u64)); + } + } +}