Spaces:
Runtime error
Runtime error
File size: 1,206 Bytes
af1695b 33c4afa 69005d5 a950c39 af1695b 37d5502 33c4afa 69005d5 ad45296 a950c39 ad45296 37d5502 69005d5 e7a363a 69005d5 e7a363a 69005d5 37d5502 a950c39 ad45296 a950c39 e7a363a a950c39 1c02b32 a950c39 1c02b32 a950c39 | 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 45 46 47 | import gradio as gr
import subprocess
import tempfile
import os
def convert_webm_to_mp4(webm_file):
if webm_file is None:
return None
tmp_dir = tempfile.mkdtemp()
mp4_path = os.path.join(tmp_dir, "output.mp4")
try:
subprocess.run(
[
"ffmpeg",
"-y",
"-i", webm_file,
"-c:v", "libx264",
"-preset", "fast",
"-crf", "23",
mp4_path
],
check=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE
)
except subprocess.CalledProcessError as e:
return f"Erro ao converter: {e.stderr.decode()}"
return mp4_path
# --- Interface Gradio ---
with gr.Blocks() as demo:
gr.Markdown("## WebM → MP4 Converter")
# <-- aqui removemos 'type' -->
webm_input = gr.Video(label="Upload WebM")
mp4_output = gr.File(label="Download MP4")
convert_btn = gr.Button("Convert to MP4")
convert_btn.click(fn=convert_webm_to_mp4, inputs=[webm_input], outputs=[mp4_output])
# Rodar app
if __name__ == "__main__":
demo.launch(server_name="0.0.0.0", server_port=7860, share=True)
|