Spaces:
Paused
Paused
Delete appOLD
Browse files
appOLD
DELETED
|
@@ -1,40 +0,0 @@
|
|
| 1 |
-
import gradio as gr
|
| 2 |
-
from gradio.components import Video
|
| 3 |
-
import os
|
| 4 |
-
from ffmpeg.input import Input
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
def transcode_video(video_path):
|
| 8 |
-
"""Transcodes a video file to m3u8 using ffmpeg.
|
| 9 |
-
Args:
|
| 10 |
-
video_path: The path to the video file to transcode.
|
| 11 |
-
Returns:
|
| 12 |
-
The path to the transcoded file.
|
| 13 |
-
"""
|
| 14 |
-
|
| 15 |
-
# Create a folder to save the transcoded video file to.
|
| 16 |
-
output_dir = os.path.dirname(video_path)
|
| 17 |
-
if not os.path.exists(output_dir):
|
| 18 |
-
os.makedirs(output_dir)
|
| 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 |
-
"output_dir/NEARHUBanimation.mp4",
|
| 30 |
-
]
|
| 31 |
-
|
| 32 |
-
# Launch a gradio interface that allows you to play the transcoded video file.
|
| 33 |
-
demo = gr.Interface(transcode_video,
|
| 34 |
-
gr.components.Video(),
|
| 35 |
-
"playable_video",
|
| 36 |
-
examples=video_files,
|
| 37 |
-
cache_examples=True)
|
| 38 |
-
|
| 39 |
-
if __name__ == "__main__":
|
| 40 |
-
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|