Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,6 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import tempfile
|
| 3 |
import subprocess
|
| 4 |
-
import os
|
| 5 |
from pathlib import Path
|
| 6 |
|
| 7 |
def convert_webm_to_mp4(webm_file):
|
|
@@ -9,14 +8,12 @@ def convert_webm_to_mp4(webm_file):
|
|
| 9 |
Recebe um arquivo WebM, converte para MP4 e retorna o caminho do MP4.
|
| 10 |
"""
|
| 11 |
if webm_file is None:
|
| 12 |
-
#
|
| 13 |
return "https://sample-videos.com/video123/mp4/240/big_buck_bunny_240p_1mb.mp4"
|
| 14 |
|
| 15 |
-
# Cria arquivo temporário para MP4
|
| 16 |
tmp_dir = tempfile.mkdtemp()
|
| 17 |
mp4_path = Path(tmp_dir) / "output.mp4"
|
| 18 |
|
| 19 |
-
# Executa conversão via ffmpeg
|
| 20 |
try:
|
| 21 |
subprocess.run([
|
| 22 |
"ffmpeg",
|
|
@@ -37,14 +34,14 @@ with gr.Blocks() as demo:
|
|
| 37 |
gr.Markdown("### WebM to MP4 Converter\nUpload a WebM video and get MP4 back.")
|
| 38 |
|
| 39 |
with gr.Row():
|
| 40 |
-
|
|
|
|
| 41 |
mp4_output = gr.Video(label="MP4 Output")
|
| 42 |
|
| 43 |
convert_btn = gr.Button("Convert")
|
| 44 |
|
| 45 |
-
#
|
| 46 |
convert_btn.click(fn=convert_webm_to_mp4, inputs=[webm_input], outputs=[mp4_output])
|
| 47 |
|
| 48 |
-
# Lançamento do app
|
| 49 |
if __name__ == "__main__":
|
| 50 |
demo.launch(server_name="0.0.0.0", server_port=7860, share=True)
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import tempfile
|
| 3 |
import subprocess
|
|
|
|
| 4 |
from pathlib import Path
|
| 5 |
|
| 6 |
def convert_webm_to_mp4(webm_file):
|
|
|
|
| 8 |
Recebe um arquivo WebM, converte para MP4 e retorna o caminho do MP4.
|
| 9 |
"""
|
| 10 |
if webm_file is None:
|
| 11 |
+
# Retorna um MP4 dummy se nenhum WebM for enviado
|
| 12 |
return "https://sample-videos.com/video123/mp4/240/big_buck_bunny_240p_1mb.mp4"
|
| 13 |
|
|
|
|
| 14 |
tmp_dir = tempfile.mkdtemp()
|
| 15 |
mp4_path = Path(tmp_dir) / "output.mp4"
|
| 16 |
|
|
|
|
| 17 |
try:
|
| 18 |
subprocess.run([
|
| 19 |
"ffmpeg",
|
|
|
|
| 34 |
gr.Markdown("### WebM to MP4 Converter\nUpload a WebM video and get MP4 back.")
|
| 35 |
|
| 36 |
with gr.Row():
|
| 37 |
+
# Aqui removemos `type="file"`
|
| 38 |
+
webm_input = gr.Video(label="WebM Input")
|
| 39 |
mp4_output = gr.Video(label="MP4 Output")
|
| 40 |
|
| 41 |
convert_btn = gr.Button("Convert")
|
| 42 |
|
| 43 |
+
# Handler Index 0
|
| 44 |
convert_btn.click(fn=convert_webm_to_mp4, inputs=[webm_input], outputs=[mp4_output])
|
| 45 |
|
|
|
|
| 46 |
if __name__ == "__main__":
|
| 47 |
demo.launch(server_name="0.0.0.0", server_port=7860, share=True)
|