Would this or another approach help with overloading my system (android Motorola g power…
- User
Would this or another approach help with overloading my system (android Motorola g power 2024) from multiprocessing import Pool import os
Path for saving frames
folder = "temp_frames" os.makedirs(folder, exist_ok=True)
Function for generating frames
def generate_frame_range(start, end, folder, cache_size=10): cache = [] for i in range(start, end): frame = None # Your frame generation logic here, keeping high quality cache.append(frame)
code# When cache is full, save the frames to disk if len(cache) >= cache_size: for idx, cached_frame in enumerate(cache): frame_path = os.path.join(folder, f"frame_{i - cache_size + idx}.png") cached_frame.save(frame_path) # Save high-quality frame cache.clear() # Clear cache to free up memory # Save remaining frames in the cache for idx, cached_frame in enumerate(cache): frame_path = os.path.join(folder, f"frame_{end - len(cache) + idx}.png") cached_frame.save(frame_path)Multi-processing to handle different frame ranges
if name == "main": frame_ranges = [(0, 100), (100, 200), (200, 300), (300, 400)] # Example with Pool(processes=4) as pool: # Adjust processes as per your phone's CPU cores pool.starmap(generate_frame_range, [(start, end, folder) for start, end in frame_ranges])
After generating frames, you can combine them into a video with MoviePy or similar
This is the script in question, I don't want to lose output quality import numpy as np import os import time from PIL import Image from moviepy.editor import VideoClip from moviepy.video.fx.all import fadein, fadeout from tqdm import tqdm
Paths
image_one_path = '/home/daddy/morph/one.jpeg' image_two_path = '/home/daddy/morph/two.jpeg' output_path = '/home/daddy/morph/output' output_filename = f'morph{int(time.time())}.mp4'
Function to create each frame of the video
def make_frame(t): if t < duration1: # Display the first image frame_array = img1_array.copy() elif t < duration1 + duration2: # Morphing effect with particle explosion and implosion progress = (t - duration1) / duration2 # Normalize progress to [0, 1]
code - Assistant