Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| import ffmpeg | |
| import os | |
| # Fonction pour découper la vidéo en frames, appliquer l'upscaling, puis reconstruire la vidéo | |
| def upscale_video(input_video): | |
| input_path = "/tmp/input_video.mp4" | |
| output_path = "/tmp/upscaled_video.mp4" | |
| # Sauvegarder la vidéo téléchargée | |
| input_video.save(input_path) | |
| # Utiliser FFmpeg pour extraire les frames de la vidéo | |
| frames_dir = "/tmp/frames/" | |
| os.makedirs(frames_dir, exist_ok=True) | |
| ffmpeg.input(input_path).output(f"{frames_dir}frame_%04d.png").run() | |
| # Appliquer un upscaling sur chaque frame | |
| for frame in os.listdir(frames_dir): | |
| frame_path = os.path.join(frames_dir, frame) | |
| upscaled_frame_path = os.path.join(frames_dir, "upscaled_" + frame) | |
| ffmpeg.input(frame_path).output(upscaled_frame_path, vf="scale=1280:720").run() | |
| # Reconstruire la vidéo avec les frames upscalées | |
| ffmpeg.input(f"{frames_dir}upscaled_%04d.png", framerate=24).output(output_path).run() | |
| # Retourner la vidéo upscalée | |
| return output_path | |
| # Interface Gradio | |
| iface = gr.Interface( | |
| fn=upscale_video, | |
| inputs=gr.Video(label="Téléchargez votre vidéo"), | |
| outputs=gr.File(label="Vidéo upscalée"), | |
| title="Upscaling de vidéo", | |
| description="Téléchargez une vidéo et augmentez sa résolution avec cette interface." | |
| ) | |
| # Lancer Gradio avec un lien partageable | |
| iface.launch(share=True) | |