Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -7,6 +7,9 @@ import tempfile
|
|
7 |
|
8 |
from pathlib import Path
|
9 |
|
|
|
|
|
|
|
10 |
video_file = gr.inputs.File(label="Video File")
|
11 |
quality = gr.inputs.Dropdown(choices=["18", "23", "28", "32"], label="Quality", default="23")
|
12 |
aspect_ratio = gr.inputs.Dropdown(choices=["16:9", "4:3", "3:2", "2:1"], label="Aspect Ratio", default="16:9")
|
@@ -15,7 +18,7 @@ def convert_video(video_file: File, quality, aspect_ratio):
|
|
15 |
output_path = f"{video_file.name}.m3u8"
|
16 |
|
17 |
temp_dir = tempfile.gettempdir()
|
18 |
-
ffmpeg_command = f"ffmpeg -i {video_file
|
19 |
subprocess.run(ffmpeg_command, shell=True)
|
20 |
|
21 |
return components.Video(output_path)
|
|
|
7 |
|
8 |
from pathlib import Path
|
9 |
|
10 |
+
# Define File object
|
11 |
+
File = Path
|
12 |
+
|
13 |
video_file = gr.inputs.File(label="Video File")
|
14 |
quality = gr.inputs.Dropdown(choices=["18", "23", "28", "32"], label="Quality", default="23")
|
15 |
aspect_ratio = gr.inputs.Dropdown(choices=["16:9", "4:3", "3:2", "2:1"], label="Aspect Ratio", default="16:9")
|
|
|
18 |
output_path = f"{video_file.name}.m3u8"
|
19 |
|
20 |
temp_dir = tempfile.gettempdir()
|
21 |
+
ffmpeg_command = f"ffmpeg -i {video_file} -c:v libx264 -crf {quality} -f hls -aspect {aspect_ratio} {temp_dir}/{output_path}"
|
22 |
subprocess.run(ffmpeg_command, shell=True)
|
23 |
|
24 |
return components.Video(output_path)
|