AlexandreScriptsMT commited on
Commit
af1695b
·
verified ·
1 Parent(s): dc140b0

Create App.py

Browse files
Files changed (1) hide show
  1. App.py +35 -0
App.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import subprocess
3
+ import uuid
4
+ import os
5
+
6
+ OUTPUT_DIR = "outputs"
7
+ os.makedirs(OUTPUT_DIR, exist_ok=True)
8
+
9
+ def webm_to_mp4(video):
10
+ input_path = video
11
+ output_name = f"{uuid.uuid4()}.mp4"
12
+ output_path = os.path.join(OUTPUT_DIR, output_name)
13
+
14
+ command = [
15
+ "ffmpeg",
16
+ "-y",
17
+ "-i", input_path,
18
+ "-movflags", "faststart",
19
+ "-pix_fmt", "yuv420p",
20
+ output_path
21
+ ]
22
+
23
+ subprocess.run(command, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
24
+
25
+ return output_path
26
+
27
+ iface = gr.Interface(
28
+ fn=webm_to_mp4,
29
+ inputs=gr.Video(format="webm"),
30
+ outputs=gr.File(label="Download MP4"),
31
+ title="WebM → MP4 Converter",
32
+ description="Envie um vídeo WebM e receba um MP4 pronto para download."
33
+ )
34
+
35
+ iface.launch()