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