Spaces:
Paused
Paused
import gradio as gr | |
import ffmpeg | |
from gradio.components import File | |
import os | |
def transcode_video(input_video_file): | |
"""Transcodes a video file to m3u8 using ffmpeg. | |
Args: | |
input_video_file: The path to the video file to transcode. | |
Returns: | |
The path to the transcoded file. | |
""" | |
# Create a folder to save the transcoded video file to. | |
output_dir = os.path.dirname(input_video_file) | |
if not os.path.exists(output_dir): | |
os.makedirs(output_dir) | |
# Transcode the video file. | |
output_file = os.path.join(output_dir, f"{input_video_file.name}.m3u8") | |
ffmpeg.input(input_video_file).output(output_file, format="hls").run() | |
# Return the path to the transcoded file. | |
return output_file | |
# Remove unused keyword argument | |
input_video_file = File() | |
outputs={"output_file": File(accept=".m3u8")} | |
gr.Interface( | |
transcode_video, | |
inputs={"input_video_file": input_video_file}, | |
outputs=outputs | |
).launch() | |