Spaces:
Paused
Paused
File size: 921 Bytes
88c7481 5a14a12 838164d 87e9456 88c7481 87e9456 88c7481 9571046 88c7481 a64acd3 87e9456 a64acd3 88c7481 87e9456 88c7481 7f52e8a 87e9456 d07ace0 87e9456 45a6dfa 87e9456 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
import gradio as gr
import ffmpeg
import os
def transcode_video(video):
"""Transcodes a video file to m3u8 using ffmpeg.
Args:
video: 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(video.path)
if not os.path.exists(output_dir):
os.makedirs(output_dir)
# Transcode the video file.
output_file = os.path.join(output_dir, f"{video.name}.m3u8" )
ffmpeg.input(video.path).output(output_file, format="hls").run()
# Return the path to the transcoded file.
return output_file
demo = gr.Interface(transcode_video,
gr.Video(),
"playable_video",
examples=[
video.path for video in gr.inputs.Video()],
cache_examples=True)
if __name__ == "__main__":
demo.launch()
|