Spaces:
Runtime error
Runtime error
| 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() | |