Jeffgold commited on
Commit
425c3f9
·
1 Parent(s): f182711

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -7
app.py CHANGED
@@ -3,29 +3,30 @@ import ffmpeg
3
  from gradio.components import Video
4
  import os
5
 
6
- def transcode_video(video):
7
  """Transcodes a video file to m3u8 using ffmpeg.
8
  Args:
9
- video: 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.name}.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
- "output_dir/NEARHUBanimation.mp4",
 
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()