Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -153,23 +153,30 @@ def convert_video(video_file, quality, aspect_ratio, video_url):
|
|
153 |
output_paths.append(master_playlist_path)
|
154 |
|
155 |
# Convert Path objects to URLs before returning
|
156 |
-
return [{
|
157 |
|
158 |
video_file = gr.File(label="Video File")
|
159 |
quality = gr.Dropdown(
|
160 |
choices=["18", "23", "27", "28", "32"], label="Quality", default="27")
|
161 |
aspect_ratio = gr.Textbox(default="16:9", lines=1, label="Aspect ratio (width:height)")
|
162 |
-
standard_resolutions =
|
163 |
-
choices=[4320, 2160, 1440, 1080, 720, 480, 360, 240, 144] # 8K, 4K, 2K, Full HD, HD, SD in pixels
|
164 |
video_url = gr.Textbox(label="Or enter video URL")
|
165 |
|
|
|
|
|
|
|
|
|
|
|
|
|
166 |
interface = gr.Interface(
|
167 |
fn=convert_video,
|
168 |
inputs=[video_file, quality, aspect_ratio, video_url],
|
169 |
-
outputs=gr.outputs.HTML(label="Download Links"),
|
170 |
title="Video Converter",
|
171 |
description="A simple video converter app",
|
172 |
allow_flagging=False,
|
173 |
)
|
174 |
interface.launch()
|
175 |
|
|
|
|
|
|
153 |
output_paths.append(master_playlist_path)
|
154 |
|
155 |
# Convert Path objects to URLs before returning
|
156 |
+
return [{'name': path.stem, 'url': f"http://localhost:{PORT}/{path.name}"} for path in output_paths]
|
157 |
|
158 |
video_file = gr.File(label="Video File")
|
159 |
quality = gr.Dropdown(
|
160 |
choices=["18", "23", "27", "28", "32"], label="Quality", default="27")
|
161 |
aspect_ratio = gr.Textbox(default="16:9", lines=1, label="Aspect ratio (width:height)")
|
162 |
+
standard_resolutions = [4320, 2160, 1440, 1080, 720, 480, 360, 240, 144] # 8K, 4K, 2K, Full HD, HD, SD in pixels
|
|
|
163 |
video_url = gr.Textbox(label="Or enter video URL")
|
164 |
|
165 |
+
def format_output(output):
|
166 |
+
html = ""
|
167 |
+
for file in output:
|
168 |
+
html += f'<p><a href="{file["url"]}">{file["name"]}</a></p>'
|
169 |
+
return html
|
170 |
+
|
171 |
interface = gr.Interface(
|
172 |
fn=convert_video,
|
173 |
inputs=[video_file, quality, aspect_ratio, video_url],
|
174 |
+
outputs=gr.outputs.HTML(label="Download Links", postprocess=format_output),
|
175 |
title="Video Converter",
|
176 |
description="A simple video converter app",
|
177 |
allow_flagging=False,
|
178 |
)
|
179 |
interface.launch()
|
180 |
|
181 |
+
|
182 |
+
|