diff --git a/.gitignore b/.gitignore index b58d83e..3e2402f 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ /src/out /output.avi /setting_tests -/output.txt \ No newline at end of file +/output.txt +/src/tests/morbius.webm \ No newline at end of file diff --git a/src/.DS_Store b/src/.DS_Store index 5694a67..82859ca 100644 Binary files a/src/.DS_Store and b/src/.DS_Store differ diff --git a/src/etcher.rs b/src/etcher.rs index a3c8259..8d17f20 100644 --- a/src/etcher.rs +++ b/src/etcher.rs @@ -171,7 +171,7 @@ fn etch_pixel(frame: &mut EmbedSource, rgb: Vec, x: i32, y: i32) -> anyhow:: fn etch_bw(source: &mut EmbedSource, data: &Vec, global_index: &mut usize) -> anyhow::Result<()> { - // let _timer = Timer::new("Etching frame"); + let _timer = Timer::new("Etching frame"); let width = source.actual_size.width; let height = source.actual_size.height; @@ -208,6 +208,7 @@ fn etch_bw(source: &mut EmbedSource, data: &Vec, global_index: &mut usize) fn etch_color(source: &mut EmbedSource, data: &Vec, global_index: &mut usize) -> anyhow::Result<()>{ + let _timer = Timer::new("Etching frame"); let width = source.actual_size.width; let height = source.actual_size.height; @@ -238,6 +239,8 @@ fn etch_color(source: &mut EmbedSource, data: &Vec, global_index: &mut usize } fn read_bw(source: &EmbedSource, current_frame: i32, final_frame: i32, final_bit: i32) -> anyhow::Result>{ + let _timer = Timer::new("Dislodging frame"); + let width = source.actual_size.width; let height = source.actual_size.height; let size = source.size as usize; @@ -270,6 +273,8 @@ fn read_bw(source: &EmbedSource, current_frame: i32, final_frame: i32, final_bit } fn read_color(source: &EmbedSource, current_frame: i32, final_frame: i32, final_byte: i32) -> anyhow::Result>{ + let _timer = Timer::new("Dislodging frame"); + let width = source.actual_size.width; let height = source.actual_size.height; let size = source.size as usize; @@ -335,6 +340,7 @@ fn etch_instructions(settings: &Settings, data: &Data) final_frame += 1; } + dbg!(final_frame); u32_instructions.push(final_frame as u32); u32_instructions.push(final_byte as u32); }, @@ -350,6 +356,7 @@ fn etch_instructions(settings: &Settings, data: &Data) final_frame += 1; } + dbg!(final_frame); u32_instructions.push(final_frame as u32); u32_instructions.push(final_byte as u32); }, @@ -517,6 +524,7 @@ pub fn etch(path: &str, data: Data, settings: Settings) -> anyhow::Result<()> { } pub fn read(path: &str, threads: usize) -> anyhow::Result> { + let _timer = Timer::new("Dislodging frame"); let instruction_size = 5; let mut video = VideoCapture::from_file(&path, CAP_ANY) diff --git a/src/main.rs b/src/main.rs index 7c31703..421d2a1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -14,27 +14,13 @@ async fn main() -> anyhow::Result<()> { println!("This tool allows you to turn any file into a compression-resistant video that can be uploaded to YouTube for Infinite Storage:tm:"); println!("\nHow to use:"); println!("1. Zip all the files you will be uploading"); - println!("2. Use the embed option on the archive (THE VIDEO WILL BE SEVERAL TIMES LARGER THAN THE FILE: original size * 8 * block size^2 = new size)"); + println!("2. Use the embed option on the archive (THE VIDEO WILL BE SEVERAL TIMES LARGER THAN THE FILE, 4x in case of optimal compression resistance preset)"); println!("3. Upload the video to your YouTube channel. You probably want to keep it up as unlisted"); println!("4. Use the download option to get the video back"); println!("5. Use the dislodge option to get your files back from the downloaded video"); - println!("6. PROFIT. Enjoy being a leech on a huge corporation's servers"); - - println!("\nI coudln't figure out a weird bug that happens if you set the size to something that isn't a factor of the height"); - println!("If you don't want the files you put in to come out as the audio/visual equivalent of a pipe bomb, account for the above bug\n"); + println!("6. PROFIT. Enjoy being a leech on a huge corporation's servers\n"); ui::summon_gooey().await?; - // let bytes = etcher::rip_bytes("src/tests/Baby.wav")?; - // let binary = etcher::rip_binary(bytes)?; - - // let data = Data::from_binary(binary); - // let settings = Settings::new(1, 30, 640, 360); - - // etcher::etch("src/out/output.avi", data, settings)?; - - // let out_data = etcher::read("src/out/output.avi")?; - - // etcher::write_bytes("src/out/Baby2.wav", out_data)?; return Ok(()); } diff --git a/src/note.txt b/src/note.txt index f7517fc..8cc3a1e 100644 --- a/src/note.txt +++ b/src/note.txt @@ -30,6 +30,18 @@ After-project: Fix weird bug Code clean-up +Benchmark notes: +430 kb/s average, 4x size, optimal resistance +320 kb/s average, 11x-12x size, paranoid resistance +31.9 mb/s average, 1x size, maximum efficiency +(A lot of this time is just creating the file after the frames are made) + +~8.5ms per frame, optimal resistance +~5.8ms per frame, paranoid resistance +~0.16ms per frame, maximum efficiency + +Probably faster on paranoid because it has to read less ? + diff --git a/src/timer.rs b/src/timer.rs index 6206f8d..dab85c7 100644 --- a/src/timer.rs +++ b/src/timer.rs @@ -12,9 +12,9 @@ impl Drop for Timer { let millis = self.time.elapsed().as_millis(); if micros < 10000 { - println!("{} ended in {}us", self.title, self.time.elapsed().as_micros()); + println!("{} ended in {}us", self.title, micros); } else { - println!("{} ended in {}ms", self.title, self.time.elapsed().as_millis()); + println!("{} ended in {}ms", self.title, millis); } } diff --git a/src/ui.rs b/src/ui.rs index f5a87a3..722591c 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -32,9 +32,9 @@ fn embed_path() -> anyhow::Result<()> { //Should use enums let presets = vec![ - "Maximum efficiency", "Optimal compression resistance", "Paranoid compression resistance", + "Maximum efficiency", "Custom" ]; @@ -88,7 +88,7 @@ fn embed_path() -> anyhow::Result<()> { let binary = etcher::rip_binary(bytes)?; let data = Data::from_binary(binary); - let settings = Settings::new(4, 8, 10, 1280, 720); + let settings = Settings::new(4, 8, 30, 1280, 720); etcher::etch("output.avi", data, settings)?; @@ -102,6 +102,9 @@ fn embed_path() -> anyhow::Result<()> { .prompt() .unwrap(); + println!("\nI coudln't figure out a weird bug that happens if you set the size to something that isn't a factor of the height"); + println!("If you don't want the files you put in to come out as the audio/visual equivalent of a pipe bomb, account for the above bug\n"); + let size = CustomType::::new("What size should the blocks be ?") .with_error_message("Please type a valid number") .with_help_message("Bigger blocks are more resistant to compression, I recommend 2-5.") @@ -111,7 +114,7 @@ fn embed_path() -> anyhow::Result<()> { let threads = CustomType::::new("How many threads to dedicate for processing ?") .with_error_message("Please type a valid number") .with_help_message("The more threads, the merrier") - .with_default(4) + .with_default(8) .prompt()?; let out_mode = match out_mode { @@ -202,7 +205,7 @@ fn dislodge_path() -> anyhow::Result<()> { let threads = CustomType::::new("How many threads to dedicate for processing ?") .with_error_message("Please type a valid number") .with_help_message("The more threads, the merrier") - .with_default(4) + .with_default(8) .prompt()?; let out_data = etcher::read(&in_path, threads)?;