├── .gitattributes ├── LICENSE ├── README.md ├── main.py └── requirements.txt /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 karmugil 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Infinite_Storage_Glitch 2 | YouTube as Cloud Storage: Store Any Files You Want 3 | 4 | ![ezgif-1-0299af809c](https://user-images.githubusercontent.com/86147453/221376499-1e7e894a-1d76-4d59-90ec-90ccf7fb6fd0.gif) 5 | 6 | How to use 7 | ------------- 8 | Install Requirments 9 | 10 | 11 | 1. Archive to zip all the files you will be uploading 12 | 2. Run the executable 13 | 3. It will give you three options file to video , video to file , download video from youtube select option you need and program will start executing 14 | 4. Upload the video to your YouTube channel. You probably want to keep it up as unlisted 15 | 5. Use the download option to get the video back 16 | 6. Use the dislodge option to get your files back from the downloaded video 17 | 7. PROFIT 18 | 19 | 20 | input file should be zipped file 21 | 22 | keep only one zip file in same directery 23 | 24 | 25 | 26 | This program inspired from DvorakDwarf Infinite-Storage-Glitch 27 | https://github.com/DvorakDwarf/Infinite-Storage-Glitch check out his project 28 | 29 | I dont know rust so I recreated the same project in python 30 | 31 | # Demo 32 | [YouTube Link](https://youtu.be/wsbZO4kmXFI) 33 | 34 | To reduce the risk of corruption, the program uses larger pixel blocks in binary mode, typically 2x2 blocks. 35 | 36 | This program consists of several functions that allow for the conversion of files to binary format, and for the creation of videos from a file. 37 | 38 | ## file_to_binary() 39 | This function takes no parameters and returns a string of 0's and 1's representing the binary data of a file with a .zip extension. It does this by first determining the file size and reading the file as binary data. The binary data is then converted to a string of 0's and 1's and returned. 40 | 41 | ## binary_to_video(bin_string, width=1920, height=1080, pixel_size=4, fps=24) 42 | This function takes a string of binary data as bin_string and several optional parameters that determine the size and framerate of the resulting video. It returns a video file in .mp4 format. The function first calculates the total number of pixels needed to represent the binary data and the number of pixels that can fit in one image. It then creates an array of frames, each of which corresponds to one image that contains the binary data. The frames are created by iterating through each row and column of binary digits and determining the color of each pixel based on the binary digit. The frames are then added to the array of frames. Finally, the frames are used to create a video file using the MoviePy library and written to disk. 43 | 44 | ## process_images(frames) 45 | This function takes an array of frames as input and returns a string of 0's and 1's representing the binary data contained in the frames. It does this by iterating through each frame and converting it to grayscale. It then iterates through each row and column of pixels and determines the binary digit based on the color of each pixel. The binary digits are concatenated into a single string and returned. 46 | 47 | ## imageToText() 48 | This function takes no parameters and prompts the user to enter the name of a file to convert to binary format. It then calls the file_to_binary() function and stores the resulting binary data in a file named binary.txt. 49 | 50 | ## binaryToFile(binary_filename) 51 | This function takes a string of binary data as binary_filename and writes it to a file named output.zip. It does this by first converting the binary data to binary format and then writing the binary data to the output file. 52 | 53 | Overall, this program provides a simple way to convert files to binary format and create videos from binary data, as well as convert binary data back to files. 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | from PIL import Image 2 | import math 3 | import os 4 | from moviepy.editor import ImageSequenceClip 5 | import imageio 6 | import numpy as np 7 | from PIL import Image 8 | import io 9 | from tqdm import tqdm 10 | from pytube import YouTube 11 | 12 | 13 | def file_to_binary(): 14 | # get file size 15 | dir_path = os.getcwd() 16 | for file_name in os.listdir(dir_path): 17 | if file_name.endswith('.mkv'): 18 | print(file_name) 19 | file_name=file_name 20 | break 21 | file_size = os.path.getsize(file_name) 22 | 23 | # read file as binary and convert to string of 0's and 1's 24 | binary_string = "" 25 | with open(file_name, "rb") as f: 26 | for chunk in tqdm(iterable=iter(lambda: f.read(1024), b""), total=math.ceil(file_size/1024), unit="KB"): 27 | binary_string += "".join(f"{byte:08b}" for byte in chunk) 28 | 29 | return binary_string 30 | 31 | # write binary string to text file 32 | 33 | 34 | def binary_to_video(bin_string, width=1920, height=1080, pixel_size=4, fps=24): 35 | # Calculate the total number of pixels needed to represent the binary string 36 | num_pixels = len(bin_string) 37 | 38 | # Calculate the number of pixels that can fit in one image 39 | pixels_per_image = (width // pixel_size) * (height // pixel_size) 40 | 41 | # Calculate the number of images needed to represent the binary string 42 | num_images = math.ceil(num_pixels / pixels_per_image) 43 | 44 | # Create an array to store the frames 45 | frames = [] 46 | 47 | # Loop through each image 48 | for i in tqdm(range(num_images)): 49 | # Calculate the range of binary digits needed for this image 50 | start_index = i * pixels_per_image 51 | end_index = min(start_index + pixels_per_image, num_pixels) 52 | binary_digits = bin_string[start_index:end_index] 53 | 54 | # Create a new image object with the given size 55 | img = Image.new('RGB', (width, height), color='white') 56 | 57 | # Loop through each row of binary digits 58 | for row_index in range(height // pixel_size): 59 | 60 | # Get the binary digits for the current row 61 | start_index = row_index * (width // pixel_size) 62 | end_index = start_index + (width // pixel_size) 63 | row = binary_digits[start_index:end_index] 64 | 65 | # Loop through each column of binary digits 66 | for col_index, digit in enumerate(row): 67 | 68 | # Determine the color of the pixel based on the binary digit 69 | if digit == '1': 70 | color = (0, 0, 0) # Black 71 | else: 72 | color = (255, 255, 255) # White 73 | 74 | # Calculate the coordinates of the pixel 75 | x1 = col_index * pixel_size 76 | y1 = row_index * pixel_size 77 | x2 = x1 + pixel_size 78 | y2 = y1 + pixel_size 79 | 80 | # Draw the pixel on the image 81 | img.paste(color, (x1, y1, x2, y2)) 82 | 83 | # Add the frame to the list of frames 84 | with io.BytesIO() as f: 85 | img.save(f, format='PNG') 86 | frame = np.array(Image.open(f)) 87 | frames.append(frame) 88 | 89 | # Create a video from the frames using MoviePy 90 | clip = ImageSequenceClip(frames, fps=fps) 91 | 92 | # Write the video to a file 93 | clip.write_videofile('video.mp4', fps=fps) 94 | 95 | 96 | def process_images(frames): 97 | # Define the threshold value for determining black pixels 98 | threshold = 128 99 | 100 | # Create an empty string to store the binary digits 101 | binary_digits = '' 102 | 103 | # Loop through each frame in the list 104 | for frame in tqdm(frames, desc="Processing frames"): 105 | # Convert the frame to grayscale 106 | gray_frame = np.mean(frame, axis=2).astype(np.uint8) 107 | 108 | # Hardcode the pixel size to 4 109 | pixel_size = 4 110 | 111 | # Loop through each row of pixels 112 | for y in range(0, gray_frame.shape[0], pixel_size): 113 | # Loop through each column of pixels 114 | for x in range(0, gray_frame.shape[1], pixel_size): 115 | # Get the color of the current pixel 116 | color = gray_frame[y:y+pixel_size, x:x+pixel_size] 117 | 118 | # Determine the binary digit based on the color of the pixel 119 | if color.mean() < threshold: 120 | binary_digits += '1' 121 | else: 122 | binary_digits += '0' 123 | 124 | # Store the binary string in a single text file 125 | return binary_digits 126 | 127 | 128 | def imageToText(): 129 | # function to convert a file to binary format and store it in a text file 130 | def file_to_binary(filename): 131 | # read file as binary 132 | with open(filename, "rb") as f: 133 | binary_data = f.read() 134 | 135 | # convert binary data to string of 0's and 1's 136 | binary_string = "".join(f"{byte:08b}" for byte in binary_data) 137 | 138 | # write binary string to text file 139 | with open("binary.txt", "w") as f: 140 | f.write(binary_string) 141 | 142 | print(f"File converted to binary format and stored in binary.txt") 143 | 144 | # prompt user to enter filename 145 | filename = input("Enter the name of the file to convert: ") 146 | 147 | # call function to convert file to binary format 148 | file_to_binary(filename) 149 | 150 | 151 | def binaryToFile(binary_filename): 152 | # convert binary string to binary data 153 | binary_data = bytes(int(binary_filename[i:i+8], 2) 154 | for i in range(0, len(binary_filename), 8)) 155 | 156 | # write binary data to output file 157 | with open("reverse.mkv", "wb") as f: 158 | with tqdm(total=len(binary_data), unit='B', unit_scale=True, desc="Writing binary data") as pbar: 159 | for chunk in range(0, len(binary_data), 1024): 160 | f.write(binary_data[chunk:chunk+1024]) 161 | pbar.update(1024) 162 | 163 | print(f"Binary data converted to example_reverse.zip") 164 | 165 | 166 | def ExtractFrames(): 167 | am = [] 168 | dir_path = os.getcwd() 169 | files = [f for f in os.listdir(dir_path) if f.endswith('.webm')] 170 | files = [f for f in os.listdir(dir_path) if f.endswith('.mp4')] 171 | files = files[0] 172 | # Open the video file 173 | vid = imageio.get_reader(files, 'ffmpeg') 174 | 175 | # Get the fps of the video 176 | fps = vid.get_meta_data()['fps'] 177 | 178 | # Get the total number of frames in the video 179 | num_frames = vid.get_length() 180 | 181 | # Use tqdm to create a progress bar 182 | with tqdm(total=num_frames) as pbar: 183 | # Iterate over every frame of the video 184 | for i, frame in enumerate(vid): 185 | # Append the frame to the list 186 | am.append(frame) 187 | # Update the progress bar 188 | pbar.update(1) 189 | 190 | # Return the list of frames 191 | return am 192 | 193 | def youtube_video_downloader(url): 194 | # create YouTube object 195 | yt = YouTube(url) 196 | 197 | # get the video with 1080p resolution 198 | stream = yt.streams.filter(res="1080p").first() 199 | 200 | # download the video 201 | stream.download() 202 | 203 | 204 | input_Data=input("convert file to video press 1 and Enter \nconvert video to file press 2 and Enter\nDownload video from youtube press 3 and Enter\n" ) 205 | 206 | if (input_Data=="1"): 207 | binary_to_video(file_to_binary()) 208 | elif(input_Data=="2"): 209 | binaryToFile(process_images(ExtractFrames())) 210 | elif(input_Data=="3"): 211 | youtube_video_downloader(input("Enter Url ")) 212 | else: 213 | print("404") 214 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | imageio==2.22.1 2 | moviepy==1.0.3 3 | numpy==1.22.4 4 | Pillow==9.4.0 5 | pytube==12.1.0 6 | tqdm==4.62.3 7 | --------------------------------------------------------------------------------