Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import subprocess
|
| 3 |
-
import os
|
| 4 |
import uuid
|
|
|
|
| 5 |
|
| 6 |
def convert_video(webm_file):
|
| 7 |
if webm_file is None:
|
|
@@ -9,37 +9,27 @@ def convert_video(webm_file):
|
|
| 9 |
|
| 10 |
output_path = f"/tmp/{uuid.uuid4()}.mp4"
|
| 11 |
|
| 12 |
-
subprocess.run(
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
with gr.Blocks() as demo:
|
| 24 |
-
gr.Markdown("## WebM → MP4 Converter")
|
| 25 |
-
|
| 26 |
-
video_input = gr.File(
|
| 27 |
-
label="Upload WebM",
|
| 28 |
-
file_types=[".webm"]
|
| 29 |
)
|
| 30 |
|
| 31 |
-
|
| 32 |
-
label="MP4 Output"
|
| 33 |
-
)
|
| 34 |
|
| 35 |
-
convert_btn = gr.Button("Convert")
|
| 36 |
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
|
|
|
| 43 |
|
| 44 |
-
|
| 45 |
-
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import subprocess
|
|
|
|
| 3 |
import uuid
|
| 4 |
+
import os
|
| 5 |
|
| 6 |
def convert_video(webm_file):
|
| 7 |
if webm_file is None:
|
|
|
|
| 9 |
|
| 10 |
output_path = f"/tmp/{uuid.uuid4()}.mp4"
|
| 11 |
|
| 12 |
+
subprocess.run(
|
| 13 |
+
[
|
| 14 |
+
"ffmpeg", "-y",
|
| 15 |
+
"-i", webm_file,
|
| 16 |
+
"-movflags", "faststart",
|
| 17 |
+
"-pix_fmt", "yuv420p",
|
| 18 |
+
output_path
|
| 19 |
+
],
|
| 20 |
+
check=True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
)
|
| 22 |
|
| 23 |
+
return output_path
|
|
|
|
|
|
|
| 24 |
|
|
|
|
| 25 |
|
| 26 |
+
iface = gr.Interface(
|
| 27 |
+
fn=convert_video,
|
| 28 |
+
inputs=gr.File(file_types=[".webm"], label="Upload WebM"),
|
| 29 |
+
outputs=gr.File(label="MP4 Output"),
|
| 30 |
+
title="WebM → MP4 Converter",
|
| 31 |
+
api_name="convert" # 🔥 AGORA É API DE VERDADE
|
| 32 |
+
)
|
| 33 |
|
| 34 |
+
iface.queue()
|
| 35 |
+
iface.launch()
|