Gave up on height buf, merging
This commit is contained in:
parent
5b98006a3d
commit
5185c2729f
2
.gitignore
vendored
2
.gitignore
vendored
@ -6,3 +6,5 @@
|
||||
/src/tests/morbius.webm
|
||||
/output.avi
|
||||
/setting_tests
|
||||
/output.txt
|
||||
/output.wav
|
42
note.txt
42
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
|
||||
@ -20,12 +51,3 @@ Fix the weird bug
|
||||
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
|
BIN
output.wav
BIN
output.wav
Binary file not shown.
@ -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 {
|
||||
|
@ -100,18 +100,12 @@ pub fn write_bytes(path: &str, data: Vec<u8>) -> anyhow::Result<()> {
|
||||
|
||||
//Returns average value of the pixel given size and location
|
||||
fn get_pixel(frame: &EmbedSource, x: i32, y: i32) -> Option<Vec<u8>> {
|
||||
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<u8> = Vec::new();
|
||||
let mut g_list: Vec<u8> = Vec::new();
|
||||
let mut b_list: Vec<u8> = 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::<opencv::core::Vec3b>(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<Vec<u8>> {
|
||||
|
||||
//Draws the pixels, exists so you can draw bigger blocks
|
||||
fn etch_pixel(frame: &mut EmbedSource, rgb: Vec<u8>, 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::<opencv::core::Vec3b>(y+i, x+j)?;
|
||||
//Opencv devs are reptilians who believe in bgr
|
||||
@ -160,13 +153,12 @@ fn etch_pixel(frame: &mut EmbedSource, rgb: Vec<u8>, 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<Ve
|
||||
|
||||
imwrite("src/out/test1.png", &source.image, &Vector::new())?;
|
||||
|
||||
let half_size = source.size/2;
|
||||
let width = source.actual_size.width;
|
||||
let height = source.actual_size.height;
|
||||
let size = source.size as usize;
|
||||
|
||||
let mut binary_data: Vec<bool> = 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<Ve
|
||||
fn read_frame(source: &EmbedSource, out_mode: &OutputMode) -> anyhow::Result<Vec<u8>>{
|
||||
// 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<Vec
|
||||
match out_mode {
|
||||
OutputMode::Color => {
|
||||
let mut byte_data: Vec<u8> = 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<Vec
|
||||
},
|
||||
OutputMode::Binary => {
|
||||
let mut binary_data: Vec<bool> = 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<Vec<u8>> {
|
||||
//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<u8> = Vec::new();
|
||||
loop {
|
||||
|
13
src/main.rs
13
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)?;
|
||||
|
15
src/ui.rs
15
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::<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 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::<i32>::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),
|
||||
|
Loading…
Reference in New Issue
Block a user