awerks commited on
Commit
6c59c25
·
1 Parent(s): 7f86bf2

Add application file

Browse files
Files changed (1) hide show
  1. app.py +18 -9
app.py CHANGED
@@ -3,10 +3,12 @@ import subprocess
3
  import os
4
  import tempfile
5
 
6
- def create_video(video_file: gr.inputs.File, subtitles_file: gr.inputs.File, debug: bool):
7
- font_size = 22
8
- font_name = "ProbaPro-Bold"
9
- border_command = f"BorderStyle=1,Outline=1.10,Shadow=0.35"
 
 
10
  output_file_handle, out_path = tempfile.mkstemp(suffix=".mp4")
11
  command = [
12
  'ffmpeg',
@@ -21,10 +23,17 @@ def create_video(video_file: gr.inputs.File, subtitles_file: gr.inputs.File, deb
21
  '-y']
22
  subprocess.run(command)
23
  os.close(output_file_handle)
24
- return out_path # return path as a string
25
-
26
- iface = gr.Interface(fn=create_video,
27
- inputs=["file", "file", "checkbox"],
28
- outputs=gr.outputs.File())
29
 
 
 
 
 
 
 
 
 
 
 
 
30
  iface.launch()
 
3
  import os
4
  import tempfile
5
 
6
+ def create_video(video_file: gr.inputs.File, subtitles_file: gr.inputs.File, font_name:str = "ProbaPro-Bold", font_size:int = 22, border_style: int = 1):
7
+ if border_style == 4:
8
+ border_command = f"BorderStyle=4,BackColour=&H30000000,Outline=0.5,Shadow=0"
9
+ else:
10
+ border_command = f"BorderStyle=1,Outline=1.10,Shadow=0.35"
11
+
12
  output_file_handle, out_path = tempfile.mkstemp(suffix=".mp4")
13
  command = [
14
  'ffmpeg',
 
23
  '-y']
24
  subprocess.run(command)
25
  os.close(output_file_handle)
26
+ return out_path
 
 
 
 
27
 
28
+ iface = gr.Interface(
29
+ fn=create_video,
30
+ inputs=[
31
+ gr.inputs.File(label="Video File"),
32
+ gr.inputs.File(label="Subtitles File"),
33
+ gr.inputs.Text(default="ProbaPro-Bold", label="Font Name"),
34
+ gr.inputs.Slider(minimum=1, maximum=30, default=22, label="Font Size"),
35
+ gr.inputs.Dropdown(choices=[1, 4], default=1, label="Border Style"),
36
+ ],
37
+ outputs=gr.outputs.File() # Replace with appropriate output type
38
+ )
39
  iface.launch()