Spaces:
Runtime error
Runtime error
File size: 1,130 Bytes
af1695b 1c02b32 af1695b 1c02b32 af1695b 1c02b32 4436f52 1c02b32 4436f52 1c02b32 3f3d364 1c02b32 af1695b 1c02b32 af1695b 1c02b32 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | import gradio as gr
import os
import uuid
import shutil
# Pasta de saída
OUTPUT_DIR = "outputs"
os.makedirs(OUTPUT_DIR, exist_ok=True)
def process_video(video_file):
"""
Função chamada tanto pela UI quanto pela API.
Recebe um arquivo e devolve um arquivo processado.
"""
if video_file is None:
raise ValueError("Nenhum arquivo enviado")
# Nome único para evitar conflito
file_id = str(uuid.uuid4())
input_path = video_file
output_path = os.path.join(OUTPUT_DIR, f"{file_id}_output.webm")
# ⚠️ AQUI entra sua lógica real
# Por enquanto, apenas copiamos o arquivo
shutil.copy(input_path, output_path)
# Retornar caminho do arquivo = link de download
return output_path
# 🔥 INTERFACE COM API EXPLÍCITA
iface = gr.Interface(
fn=process_video,
inputs=gr.File(label="Upload do vídeo"),
outputs=gr.File(label="Download do resultado"),
title="Conversor de Vídeo",
description="Envie um vídeo e receba o arquivo processado.",
api_name="predict" # 👈 ISSO É O MAIS IMPORTANTE
)
if __name__ == "__main__":
iface.launch() |