Spaces:
Paused
Paused
File size: 822 Bytes
c8942d9 72c532f 7a80d3a c8942d9 5296733 11f8d05 1271fd0 d0d220f 11f8d05 c5f2265 06412df 5296733 c5f2265 72c532f 05649bb 7a80d3a 5296733 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
import gradio as gr
import ffmpeg
import subprocess
from gradio import components
import tempfile
video_file = gr.inputs.File(label="Video File")
quality = gr.inputs.Dropdown(choices=["18", "23", "28", "32"], label="Quality", default="23")
aspect_ratio = gr.inputs.Dropdown(choices=["16:9", "4:3", "3:2", "2:1"], label="Aspect Ratio", default="16:9")
def convert_video(video_file: File, quality, aspect_ratio):
output_path = f"{video_file.name}.m3u8"
temp_dir = tempfile.gettempdir()
ffmpeg_command = f"ffmpeg -i {video_file.path} -c:v libx264 -crf {quality} -f hls -aspect {aspect_ratio} {temp_dir}/{output_path}"
subprocess.run(ffmpeg_command, shell=True)
return components.Video(output_path)
gr.Interface(convert_video, inputs=[video_file, quality, aspect_ratio], outputs=[components.Video()]).launch()
|