Jeffgold commited on
Commit
7148179
·
1 Parent(s): 91fa878

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -8
app.py CHANGED
@@ -5,24 +5,22 @@ from gradio.components import File
5
 
6
  import os
7
 
8
- def transcode_video(input_video_file, output_file, output_format, output_fps):
9
  """Transcodes a video file to m3u8 using ffmpeg.
10
  Args:
11
  input_video_file: The path to the video file to transcode.
12
- output_file: The path to the transcoded m3u8 file.
13
- output_format: The output format of the transcoded file.
14
- output_fps: The output framerate of the transcoded file.
15
  Returns:
16
  The path to the transcoded file.
17
  """
18
 
19
  # Create a folder to save the transcoded video file to.
20
- output_dir = os.path.dirname(output_file)
21
  if not os.path.exists(output_dir):
22
  os.makedirs(output_dir)
23
 
24
  # Transcode the video file.
25
- ffmpeg.input(input_video_file).output(output_file, format=output_format, fps=output_fps).run()
 
26
 
27
  # Return the path to the transcoded file.
28
  return output_file
@@ -30,11 +28,10 @@ def transcode_video(input_video_file, output_file, output_format, output_fps):
30
  # Remove unused keyword argument
31
  input_video_file = File()
32
 
33
- outputs={"output_file": File(input_video_file.path, accept=".m3u8")}
34
 
35
  gr.Interface(
36
  transcode_video,
37
  inputs={"input_video_file": input_video_file},
38
  outputs=outputs
39
  ).launch()
40
-
 
5
 
6
  import os
7
 
8
+ def transcode_video(input_video_file):
9
  """Transcodes a video file to m3u8 using ffmpeg.
10
  Args:
11
  input_video_file: The path to the video file to transcode.
 
 
 
12
  Returns:
13
  The path to the transcoded file.
14
  """
15
 
16
  # Create a folder to save the transcoded video file to.
17
+ output_dir = os.path.dirname(input_video_file)
18
  if not os.path.exists(output_dir):
19
  os.makedirs(output_dir)
20
 
21
  # Transcode the video file.
22
+ output_file = os.path.join(output_dir, f"{input_video_file.name}.m3u8")
23
+ ffmpeg.input(input_video_file).output(output_file, format="hls").run()
24
 
25
  # Return the path to the transcoded file.
26
  return output_file
 
28
  # Remove unused keyword argument
29
  input_video_file = File()
30
 
31
+ outputs={"output_file": File(accept=".m3u8")}
32
 
33
  gr.Interface(
34
  transcode_video,
35
  inputs={"input_video_file": input_video_file},
36
  outputs=outputs
37
  ).launch()