File size: 1,011 Bytes
88c7481
4dac278
5a14a12
838164d
d5bec4e
 
425c3f9
88c7481
 
425c3f9
88c7481
9571046
88c7481
 
a64acd3
425c3f9
a64acd3
 
 
88c7481
425c3f9
d5bec4e
88c7481
 
 
 
7f52e8a
12f54ee
128e862
12f54ee
 
87e9456
4dac278
87e9456
12f54ee
87e9456
45a6dfa
87e9456
d5bec4e
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
37
38
39
import gradio as gr
from gradio.components import Video
import os

from ffmpeg.input import Input

def transcode_video(video_path):
  """Transcodes a video file to m3u8 using ffmpeg.
  Args:
    video_path: 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(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_path.split('/')[-1]}.m3u8" )
  Input(video_path).output(output_file, format="hls").run()

  # Return the path to the transcoded file.
  return output_file


video_files = [
  "/path/to/NEARHUBanimation.mp4",
]

demo = gr.Interface(transcode_video, 
                    gr.components.Video(), 
                    "playable_video", 
                    examples=video_files, 
                    cache_examples=True)

if __name__ == "__main__":
    demo.launch()