diff --git a/.gitignore b/.gitignore index bf330f4..0caddd9 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,6 @@ /src/tests/ytvid.mkv /src/tests/morbius.webm /output.avi -/setting_tests \ No newline at end of file +/setting_tests +/output.txt +/output.wav \ No newline at end of file diff --git a/note.txt b/note.txt index 453c927..ae26301 100644 --- a/note.txt +++ b/note.txt @@ -9,7 +9,38 @@ Optimize: Find a tool for optimization GET RID OF THAT FUCKING CLONE (Doesn't matter much) Multithreading (thread # agnostic) -Fix the weird bug +Test more b/w formats + What leads to max compression resistance and min runtime + See if lower resolution changes anything +u32 instructions + Might still be not enough, idk + Used for end-of-file pointers + Convert every instruction to u32 +Add standard loadout + + + + + + + + + + + + + + + + + + + + + + + +Fix the weird bug (GIVED UP, DO LATER) Make blocks start from top right corner (Gives me even sizes) make it so differentiates between regular, 16:9 size and actual size Embedding or reading an imperfect causes bugs @@ -19,13 +50,4 @@ Fix the weird bug I noticed that every second frame seems broken It stops me from using anything other than 360p/720p Might have something built in - Might be the length of file written in instructions -Test more b/w formats - What leads to max compression resistance and min runtime - See if lower resolution changes anything -u32 instructions - Might still be not enough, idk - Used for end-of-file pointers - Convert every instruction to u32 - -Use branches \ No newline at end of file + Might be the length of file written in instructions \ No newline at end of file diff --git a/output.wav b/output.wav index cfebbcc..aa3e80b 100644 Binary files a/output.wav and b/output.wav differ diff --git a/src/embedsource.rs b/src/embedsource.rs index 230591b..14ce860 100644 --- a/src/embedsource.rs +++ b/src/embedsource.rs @@ -14,11 +14,11 @@ impl EmbedSource { pub fn new(size: i32, width: i32, height: i32) -> EmbedSource { let frame_size = Size::new(width, height); - let width = width - (width % size); - let height = height - (height % size); - let actual_size = Size::new(width, height); + let actual_width = width - (width % size); + let actual_height = height - (height % size); + let actual_size = Size::new(actual_width, actual_height); - // dbg!(width, height); + // dbg!(actual_size); //WHy does this have to be unsafe smh unsafe { diff --git a/src/etcher.rs b/src/etcher.rs index 9be0869..eee087a 100644 --- a/src/etcher.rs +++ b/src/etcher.rs @@ -100,18 +100,12 @@ pub fn write_bytes(path: &str, data: Vec) -> anyhow::Result<()> { //Returns average value of the pixel given size and location fn get_pixel(frame: &EmbedSource, x: i32, y: i32) -> Option> { - if frame.size % 2 != 1 { - panic!("Used even size for pixels, please choose something odd"); - } - - let half_size = frame.size/2; - let mut r_list: Vec = Vec::new(); let mut g_list: Vec = Vec::new(); let mut b_list: Vec = Vec::new(); - for i in -half_size..half_size+1 { - for j in -half_size..half_size+1 { + for i in 0..frame.size { + for j in 0..frame.size { let bgr = frame.image.at_2d::(y+i, x+j).unwrap(); //could reduce size of integers ? r_list.push(bgr[2]); @@ -141,10 +135,9 @@ fn get_pixel(frame: &EmbedSource, x: i32, y: i32) -> Option> { //Draws the pixels, exists so you can draw bigger blocks fn etch_pixel(frame: &mut EmbedSource, rgb: Vec, x: i32, y: i32) -> anyhow::Result<()> { - let half_size = frame.size/2; - for i in -half_size..half_size+1 { - for j in -half_size..half_size+1 { + for i in 0..frame.size { + for j in 0..frame.size { // dbg!(x, y); let bgr = frame.image.at_2d_mut::(y+i, x+j)?; //Opencv devs are reptilians who believe in bgr @@ -159,14 +152,13 @@ fn etch_pixel(frame: &mut EmbedSource, rgb: Vec, x: i32, y: i32) -> anyhow:: fn etch_frame(source: &mut EmbedSource, data: &Data, global_index: &mut usize) -> anyhow::Result<()>{ - - let half_size = source.size/2; + let width = source.actual_size.width; let height = source.actual_size.height; let size = source.size as usize; - for y in (half_size..height).step_by(size) { - for x in (half_size..width).step_by(size) { + for y in (0..height).step_by(size) { + for x in (0..width).step_by(size) { // dbg!(&global_index); let local_index = global_index.clone(); @@ -231,14 +223,13 @@ fn read_frame2(source: &EmbedSource, out_mode: &OutputMode) -> anyhow::Result = Vec::new(); - for y in (half_size..height).step_by(size) { - for x in (half_size..width).step_by(size) { + for y in (0..height).step_by(size) { + for x in (0..width).step_by(size) { let rgb = get_pixel(source, x, y).unwrap(); // dbg!(&rgb); if rgb[0] > 130 { @@ -256,7 +247,6 @@ fn read_frame2(source: &EmbedSource, out_mode: &OutputMode) -> anyhow::Result anyhow::Result>{ // let _timer = Timer::new("Reading frame"); - let half_size = source.size/2; let width = source.actual_size.width; let height = source.actual_size.height; let size = source.size as usize; @@ -267,8 +257,8 @@ fn read_frame(source: &EmbedSource, out_mode: &OutputMode) -> anyhow::Result { let mut byte_data: Vec = Vec::new(); - for y in (half_size..height).step_by(size) { - for x in (half_size..width).step_by(size) { + for y in (0..height).step_by(size) { + for x in (0..width).step_by(size) { let rgb = get_pixel(&source, x, y); if rgb == None { continue; @@ -285,8 +275,8 @@ fn read_frame(source: &EmbedSource, out_mode: &OutputMode) -> anyhow::Result { let mut binary_data: Vec = Vec::new(); - for y in (half_size..height).step_by(size) { - for x in (half_size..width).step_by(size) { + for y in (0..height).step_by(size) { + for x in (0..width).step_by(size) { let rgb = get_pixel(&source, x, y); if rgb == None { continue; @@ -419,10 +409,7 @@ pub fn etch(path: &str, data: Data, settings: Settings) -> anyhow::Result<()> { let fourcc = VideoWriter::fourcc('p', 'n', 'g', ' ')?; //Check if frame_size is flipped - let frame_size = frames[0].frame_size; - dbg!(&frame_size); - let actual_size = frames[1].actual_size; - dbg!(&actual_size); + let frame_size = frames[1].frame_size; let mut video = VideoWriter::new(path, fourcc, settings.fps, frame_size, true)?; //Putting them in vector might be slower @@ -449,8 +436,8 @@ pub fn read(path: &str) -> anyhow::Result> { //TEMPORARY let instruction_source = EmbedSource::from(frame.clone(), instruction_size); let (out_mode, settings) = read_instructions(&instruction_source)?; - dbg!(&settings); - dbg!(&out_mode); + // dbg!(&settings); + // dbg!(&out_mode); let mut byte_data: Vec = Vec::new(); loop { diff --git a/src/main.rs b/src/main.rs index 9772f1c..22e4fbc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,6 +10,19 @@ use settings::{Data, Settings}; //Make it calculate how much data is jammed in 1 frame for user #[tokio::main] async fn main() -> anyhow::Result<()> { + println!("Welcome to ISG (Infinite Storage Glitch)"); + 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!("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"); + println!("6. PROFIT. Enjoy being a leech on a huge corporation's servers"); + + println!("\nI coudln't figure out a weird bug where 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"); + ui::summon_gooey().await?; // let bytes = etcher::rip_bytes("src/tests/Baby.wav")?; // let binary = etcher::rip_binary(bytes)?; diff --git a/src/ui.rs b/src/ui.rs index 094544e..88390b9 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -8,7 +8,6 @@ use crate::settings::{Settings, OutputMode, Data}; use crate::etcher; pub async fn summon_gooey() -> anyhow::Result<()> { - let options = vec![ "Embed", "Download", @@ -37,7 +36,9 @@ fn embed_path() -> anyhow::Result<()> { let resolutions = vec![ "144p", + "240p", "360p", + "480p", "720p", ]; @@ -48,8 +49,8 @@ fn embed_path() -> anyhow::Result<()> { 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 5-15 if you use this feature.") - .with_default(1) + .with_help_message("Bigger blocks are more resistant to compression, I recommend 2-5.") + .with_default(2) .prompt()?; let out_mode = match out_mode { @@ -60,14 +61,14 @@ fn embed_path() -> anyhow::Result<()> { let fps = CustomType::::new("What fps should the video be at ?") .with_error_message("Please type a valid number") - .with_help_message("Decreasing fps may decrease chance of compression") + .with_help_message("Decreasing fps may decrease chance of compression. ~10fps works") .with_default(30) .prompt() .expect("Invalid fps"); //Check if higher resolution runs faster let resolution = Select::new("Pick a resolution", resolutions) - .with_help_message("I recommend 360p") + .with_help_message("I recommend 720p as the resolution won't affect compression") .prompt() .unwrap(); @@ -75,10 +76,8 @@ fn embed_path() -> anyhow::Result<()> { .with_default("src/tests/Baby.wav") .prompt().unwrap(); - //"144p" => (192, 144), - //For some reason only 360p and 720p work let (width, height) = match resolution { - "144p" => (100, 100), + "144p" => (256, 144), "240p" => (426, 240), "360p" => (640, 360), "480p" => (854, 480),