It's finally doing it but the output video is very 8bit looking, it's a ranging in…
- User
It's finally doing it but the output video is very 8bit looking, it's a ranging in colors but it making it appear to be in lines. I want it to look smooth, very cool is what I'd like.. Here's the script talk to me before u rewrite it. import numpy as np import os import time from PIL import Image from moviepy.editor import VideoClip, ImageSequenceClip from moviepy.video.fx.all import fadein, fadeout from tqdm import tqdm from multiprocessing import Pool from functools import partial
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, img1_array, img2_array, particle_positions, explosion_offsets, particle_to_target_position, duration1, duration2, duration3, width, height, particle_size): 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]
# Create an empty frame with transparency frame_array = np.zeros_like(img1_array) for idx, (x, y) in enumerate(particle_positions): # Extract the patch from the first image patch = img1_array[y:y + particle_size, x:x + particle_size].copy() # Explosion offsets offset_x, offset_y = explosion_offsets[idx] if progress < 0.5: # Explosion phase explosion_progress = progress * 2 # Scale progress to [0, 1] current_x = x + explosion_progress * offset_x current_y = y + explosion_progress * offset_y else: # Implosion phase implosion_progress = (progress - 0.5) * 2 # Scale progress to [0, 1] # Target positions in the second image target_x, target_y = particle_to_target_position.get((x, y), (x, y)) # Current position moves from exploded position to target position current_x = (x + offset_x) + implosion_progress * (target_x - (x + offset_x)) current_y = (y + offset_y) + implosion_progress * (target_y - (y + offset_y)) # Convert positions to integers and ensure they stay within frame boundaries current_x = int(np.clip(current_x, 0, width - particle_size)) current_y = int(np.clip(current_y, 0, height - particle_size)) # Place the current patch onto the frame frame_array[current_y:current_y + particle_size, current_x:current_x + particle_size] = patch else: # Hold the last frame where particles have formed the letters frame_array = np.zeros_like(img1_array) for idx, (x, y) in enumerate(particle_positions): # Extract the patch from the first image patch = img1_array[y:y + particle_size, x:x + particle_size].copy() # Target positions in the second image target_x, target_y = particle_to_target_position.get((x, y), (x, y)) # Ensure positions are within frame boundaries current_x = int(np.clip(target_x, 0, width - particle_size)) current_y = int(np.clip(target_y, 0, height - particle_size)) # Place the patch at the target position frame_array[current_y:current_y + particle_size, current_x:current_x + particle_size] = patch # Convert the NumPy array back to an image frame_image = Image.fromarray(frame_array, 'RGBA') # Return frame as an RGB image (MoviePy expects RGB format) return np.array(frame_image.convert('RGB')) - Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.