import cv2 import os import time # Ensemble de caractères par intensité ASCII_CHARS = "@%#*+=-:. " def resize_frame(frame, new_width=120): height, width = frame.shape ratio = height / width / 1.65 # correction pour terminal new_height = int(new_width * ratio) resized = cv2.resize(frame, (new_width, new_height)) return resized def gray_to_ascii(gray_frame): ascii_frame = "" for row in gray_frame: for pixel in row: ascii_frame += ASCII_CHARS[pixel // 25] ascii_frame += "\n" return ascii_frame def play_video(path): cap = cv2.VideoCapture(path) while cap.isOpened(): ret, frame = cap.read() if not ret: break gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) resized = resize_frame(gray) ascii_frame = gray_to_ascii(resized) os.system("cls" if os.name == "nt" else "clear") print(ascii_frame) time.sleep(0.03) # ~30 FPS cap.release() if __name__ == "__main__": play_video("media1.mp4") # remplace par ton fichier