Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -36,30 +36,6 @@ def get_output_path(input_path, temp_dir, res):
|
|
| 36 |
output_path = temp_dir / (Path(input_path).stem + f"_{res}.m3u8")
|
| 37 |
return output_path
|
| 38 |
|
| 39 |
-
def process_output(output):
|
| 40 |
-
"""Process output and display it appropriately."""
|
| 41 |
-
if isinstance(output, str):
|
| 42 |
-
# If output is a string, assume it's an error message and display it as text.
|
| 43 |
-
return gr.outputs.Textbox()(output)
|
| 44 |
-
elif isinstance(output, Path):
|
| 45 |
-
# If output is a Path, assume it's an error file and provide it as a downloadable file.
|
| 46 |
-
return gr.outputs.File()(str(output))
|
| 47 |
-
elif isinstance(output, list):
|
| 48 |
-
# If output is a list, assume it's a list of Paths or URLs and display it as a markdown list.
|
| 49 |
-
return gr.outputs.Markdown()("\n".join(f"- {o}" for o in output))
|
| 50 |
-
else:
|
| 51 |
-
raise TypeError("Unexpected output type")
|
| 52 |
-
|
| 53 |
-
gr.Interface(
|
| 54 |
-
convert_video,
|
| 55 |
-
inputs=[video_file, quality, aspect_ratio, video_url, api_key, upload],
|
| 56 |
-
outputs=gr.outputs.Any(),
|
| 57 |
-
output_processor=process_output,
|
| 58 |
-
allow_flagging=False,
|
| 59 |
-
live=False,
|
| 60 |
-
).launch()
|
| 61 |
-
|
| 62 |
-
|
| 63 |
def get_aspect_ratio(input_path, aspect_ratio):
|
| 64 |
"""Returns the aspect ratio of the video, calculating it if necessary."""
|
| 65 |
if aspect_ratio is not None:
|
|
|
|
| 36 |
output_path = temp_dir / (Path(input_path).stem + f"_{res}.m3u8")
|
| 37 |
return output_path
|
| 38 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
def get_aspect_ratio(input_path, aspect_ratio):
|
| 40 |
"""Returns the aspect ratio of the video, calculating it if necessary."""
|
| 41 |
if aspect_ratio is not None:
|