This commit is contained in:
HistidineDwarf 2023-02-15 19:51:28 -08:00
commit d20da7d376
7 changed files with 34 additions and 24 deletions

3
.gitignore vendored
View File

@ -3,4 +3,5 @@
/src/out
/output.avi
/setting_tests
/output.txt
/output.txt
/src/tests/morbius.webm

BIN
src/.DS_Store vendored

Binary file not shown.

View File

@ -171,7 +171,7 @@ fn etch_pixel(frame: &mut EmbedSource, rgb: Vec<u8>, x: i32, y: i32) -> anyhow::
fn etch_bw(source: &mut EmbedSource, data: &Vec<bool>, 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<bool>, global_index: &mut usize)
fn etch_color(source: &mut EmbedSource, data: &Vec<u8>, 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<u8>, global_index: &mut usize
}
fn read_bw(source: &EmbedSource, current_frame: i32, final_frame: i32, final_bit: i32) -> anyhow::Result<Vec<bool>>{
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<Vec<u8>>{
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<Vec<u8>> {
let _timer = Timer::new("Dislodging frame");
let instruction_size = 5;
let mut video = VideoCapture::from_file(&path, CAP_ANY)

View File

@ -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(());
}

View File

@ -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 ?

View File

@ -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);
}
}

View File

@ -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::<i32>::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::<usize>::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::<usize>::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)?;