Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,8 +1,9 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
import ffmpeg
|
| 3 |
from gradio.components import Video
|
| 4 |
import os
|
| 5 |
|
|
|
|
|
|
|
| 6 |
def transcode_video(video_path):
|
| 7 |
"""Transcodes a video file to m3u8 using ffmpeg.
|
| 8 |
Args:
|
|
@@ -18,14 +19,15 @@ def transcode_video(video_path):
|
|
| 18 |
|
| 19 |
# Transcode the video file.
|
| 20 |
output_file = os.path.join(output_dir, f"{video_path.split('/')[-1]}.m3u8" )
|
| 21 |
-
|
| 22 |
|
| 23 |
# Return the path to the transcoded file.
|
| 24 |
return output_file
|
| 25 |
|
| 26 |
|
| 27 |
video_files = [
|
| 28 |
-
|
|
|
|
| 29 |
]
|
| 30 |
|
| 31 |
demo = gr.Interface(transcode_video,
|
|
@@ -35,4 +37,4 @@ demo = gr.Interface(transcode_video,
|
|
| 35 |
cache_examples=True)
|
| 36 |
|
| 37 |
if __name__ == "__main__":
|
| 38 |
-
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
from gradio.components import Video
|
| 3 |
import os
|
| 4 |
|
| 5 |
+
from ffmpeg.input import Input
|
| 6 |
+
|
| 7 |
def transcode_video(video_path):
|
| 8 |
"""Transcodes a video file to m3u8 using ffmpeg.
|
| 9 |
Args:
|
|
|
|
| 19 |
|
| 20 |
# Transcode the video file.
|
| 21 |
output_file = os.path.join(output_dir, f"{video_path.split('/')[-1]}.m3u8" )
|
| 22 |
+
Input(video_path).output(output_file, format="hls").run()
|
| 23 |
|
| 24 |
# Return the path to the transcoded file.
|
| 25 |
return output_file
|
| 26 |
|
| 27 |
|
| 28 |
video_files = [
|
| 29 |
+
"/path/to/video1.mp4",
|
| 30 |
+
"/path/to/video2.mp4",
|
| 31 |
]
|
| 32 |
|
| 33 |
demo = gr.Interface(transcode_video,
|
|
|
|
| 37 |
cache_examples=True)
|
| 38 |
|
| 39 |
if __name__ == "__main__":
|
| 40 |
+
demo.launch()
|