Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| import subprocess | |
| import os | |
| import uuid | |
| def convert_video(webm_file): | |
| if webm_file is None: | |
| return None | |
| output_path = f"/tmp/{uuid.uuid4()}.mp4" | |
| subprocess.run([ | |
| "ffmpeg", "-y", | |
| "-i", webm_file, | |
| "-movflags", "faststart", | |
| "-pix_fmt", "yuv420p", | |
| output_path | |
| ], check=True) | |
| return output_path | |
| with gr.Blocks() as demo: | |
| gr.Markdown("## WebM → MP4 Converter") | |
| video_input = gr.File( | |
| label="Upload WebM", | |
| file_types=[".webm"] | |
| ) | |
| video_output = gr.File( | |
| label="MP4 Output" | |
| ) | |
| convert_btn = gr.Button("Convert") | |
| convert_btn.click( | |
| fn=convert_video, | |
| inputs=video_input, | |
| outputs=video_output, | |
| api_name="convert" # 🔥 ISSO É O QUE ESTAVA FALTANDO | |
| ) | |
| demo.queue() # 🔥 OBRIGATÓRIO | |
| demo.launch() | |