Jeffgold commited on
Commit
231a75b
·
1 Parent(s): 128e862

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -26
app.py CHANGED
@@ -1,34 +1,18 @@
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:
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
- "/path/to/NEARHUBanimation.mp4",
30
- ]
31
 
 
32
  demo = gr.Interface(transcode_video,
33
  gr.components.Video(),
34
  "playable_video",
 
1
+ import huggingface_spaces as hfs
 
 
2
 
3
+ # Create a space.
4
+ space = hfs.create_space("my-space")
5
 
6
+ # Install the `ffmpeg-input` module in the space.
7
+ space.install_package("ffmpeg-input")
 
 
 
 
 
8
 
9
+ # Upload the video file to the space.
10
+ space.upload_file("/path/to/NEARHUBanimation.mp4")
 
 
11
 
12
+ # Transcode the video file.
13
+ space.run_script("transcode_video.py")
 
 
 
 
 
 
 
 
 
14
 
15
+ # Launch a gradio interface that allows you to play the transcoded video file.
16
  demo = gr.Interface(transcode_video,
17
  gr.components.Video(),
18
  "playable_video",