# create_demo_gif.py import imageio import cv2 import os def create_demo_gif(video_path, output_path='demo.gif', duration=0.5): """Create GIF from video for portfolio""" reader = imageio.get_reader(video_path) fps = reader.get_meta_data()['fps'] # Extract frames (every 3rd frame) frames = [] for i, frame in enumerate(reader): if i % 3 == 0: # Convert to RGB frame_rgb = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB) frames.append(frame_rgb) if len(frames) >= 20: # Limit GIF length break # Save as GIF imageio.mimsave(output_path, frames, duration=duration) print(f"✅ GIF saved to {output_path}") # Usage create_demo_gif('demo_video.mp4')