Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -3,29 +3,30 @@ import ffmpeg
|
|
3 |
from gradio.components import Video
|
4 |
import os
|
5 |
|
6 |
-
def transcode_video(
|
7 |
"""Transcodes a video file to m3u8 using ffmpeg.
|
8 |
Args:
|
9 |
-
|
10 |
Returns:
|
11 |
The path to the transcoded file.
|
12 |
"""
|
13 |
|
14 |
# Create a folder to save the transcoded video file to.
|
15 |
-
output_dir = os.path.dirname(
|
16 |
if not os.path.exists(output_dir):
|
17 |
os.makedirs(output_dir)
|
18 |
|
19 |
# Transcode the video file.
|
20 |
-
output_file = os.path.join(output_dir, f"{
|
21 |
-
ffmpeg.input(
|
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 +36,4 @@ demo = gr.Interface(transcode_video,
|
|
35 |
cache_examples=True)
|
36 |
|
37 |
if __name__ == "__main__":
|
38 |
-
demo.launch()
|
|
|
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:
|
9 |
+
video_path: The path to the video file to transcode.
|
10 |
Returns:
|
11 |
The path to the transcoded file.
|
12 |
"""
|
13 |
|
14 |
# Create a folder to save the transcoded video file to.
|
15 |
+
output_dir = os.path.dirname(video_path)
|
16 |
if not os.path.exists(output_dir):
|
17 |
os.makedirs(output_dir)
|
18 |
|
19 |
# Transcode the video file.
|
20 |
+
output_file = os.path.join(output_dir, f"{video_path.split('/')[-1]}.m3u8" )
|
21 |
+
ffmpeg.input(video_path).output(output_file, format="hls").run()
|
22 |
|
23 |
# Return the path to the transcoded file.
|
24 |
return output_file
|
25 |
|
26 |
|
27 |
video_files = [
|
28 |
+
"/path/to/video1.mp4",
|
29 |
+
"/path/to/video2.mp4",
|
30 |
]
|
31 |
|
32 |
demo = gr.Interface(transcode_video,
|
|
|
36 |
cache_examples=True)
|
37 |
|
38 |
if __name__ == "__main__":
|
39 |
+
demo.launch()
|