Spaces:
Runtime error
Runtime error
File size: 1,528 Bytes
0140812 |
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 44 |
import gradio as gr
import os
from video_analyzer_keyframes import VideoSceneAnalyzer
import shutil
def process_video_keyframes(video_file):
video_path = video_file
output_dir = "output"
if not os.path.exists(video_path):
return "❌ Erro: vídeo não encontrado.", None
try:
analyzer = VideoSceneAnalyzer(video_path)
if not analyzer.load_video():
return "❌ Erro ao carregar vídeo", None
analyzer.extract_keyframes()
result_file = analyzer.save_results()
analyzer.cleanup()
if not os.path.exists(output_dir):
os.makedirs(output_dir)
shutil.copy(result_file, os.path.join(output_dir, os.path.basename(result_file)))
return f"✅ Análise por quadros-chave concluída! Resultados salvos em: {result_file}", os.path.join(output_dir, os.path.basename(result_file))
except Exception as e:
return f"❌ Erro inesperado: {e}", None
with gr.Blocks(title="🎬 Veo3 Keyframe Prompt Generator") as demo:
gr.Markdown("## 🎞️ Geração de prompts cinematográficos a partir de quadros-chave do vídeo")
with gr.Row():
video_input = gr.Video(label="📹 Envie seu vídeo (MP4)")
submit_btn = gr.Button("🚀 Analisar quadros-chave")
output_text = gr.Textbox(label="📝 Resultado")
output_file = gr.File(label="📄 JSON com prompts", visible=True)
submit_btn.click(fn=process_video_keyframes, inputs=[video_input], outputs=[output_text, output_file])
demo.launch()
|