Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,17 +4,12 @@ import tempfile
|
|
| 4 |
import os
|
| 5 |
|
| 6 |
def convert_webm_to_mp4(webm_file):
|
| 7 |
-
"""
|
| 8 |
-
Recebe um arquivo WebM enviado pelo App Builder,
|
| 9 |
-
converte para MP4 usando ffmpeg e retorna o caminho do arquivo MP4.
|
| 10 |
-
"""
|
| 11 |
if webm_file is None:
|
| 12 |
return None
|
| 13 |
|
| 14 |
tmp_dir = tempfile.mkdtemp()
|
| 15 |
mp4_path = os.path.join(tmp_dir, "output.mp4")
|
| 16 |
|
| 17 |
-
# Comando ffmpeg para conversão
|
| 18 |
subprocess.run(
|
| 19 |
["ffmpeg", "-y", "-i", webm_file, "-c:v", "libx264", mp4_path],
|
| 20 |
check=True
|
|
@@ -27,9 +22,7 @@ iface = gr.Interface(
|
|
| 27 |
fn=convert_webm_to_mp4,
|
| 28 |
inputs=gr.Video(label="Upload WebM"),
|
| 29 |
outputs=gr.File(label="Download MP4"),
|
| 30 |
-
allow_flagging="never" # desativa flags
|
| 31 |
)
|
| 32 |
|
| 33 |
if __name__ == "__main__":
|
| 34 |
-
# roda na porta 7860 e permite link público
|
| 35 |
iface.launch(server_name="0.0.0.0", server_port=7860, share=True)
|
|
|
|
| 4 |
import os
|
| 5 |
|
| 6 |
def convert_webm_to_mp4(webm_file):
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
if webm_file is None:
|
| 8 |
return None
|
| 9 |
|
| 10 |
tmp_dir = tempfile.mkdtemp()
|
| 11 |
mp4_path = os.path.join(tmp_dir, "output.mp4")
|
| 12 |
|
|
|
|
| 13 |
subprocess.run(
|
| 14 |
["ffmpeg", "-y", "-i", webm_file, "-c:v", "libx264", mp4_path],
|
| 15 |
check=True
|
|
|
|
| 22 |
fn=convert_webm_to_mp4,
|
| 23 |
inputs=gr.Video(label="Upload WebM"),
|
| 24 |
outputs=gr.File(label="Download MP4"),
|
|
|
|
| 25 |
)
|
| 26 |
|
| 27 |
if __name__ == "__main__":
|
|
|
|
| 28 |
iface.launch(server_name="0.0.0.0", server_port=7860, share=True)
|