AlexandreScriptsMT commited on
Commit
9a470b2
·
verified ·
1 Parent(s): 33c4afa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -30
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
- "ffmpeg", "-y",
14
- "-i", webm_file,
15
- "-movflags", "faststart",
16
- "-pix_fmt", "yuv420p",
17
- output_path
18
- ], check=True)
19
-
20
- return output_path
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
- video_output = gr.File(
32
- label="MP4 Output"
33
- )
34
 
35
- convert_btn = gr.Button("Convert")
36
 
37
- convert_btn.click(
38
- fn=convert_video,
39
- inputs=video_input,
40
- outputs=video_output,
41
- api_name="convert" # 🔥 ISSO É O QUE ESTAVA FALTANDO
42
- )
 
43
 
44
- demo.queue() # 🔥 OBRIGATÓRIO
45
- demo.launch()
 
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()