Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -13,6 +13,8 @@ output_dir.mkdir(exist_ok=True)
|
|
13 |
|
14 |
logging.basicConfig(level=logging.INFO)
|
15 |
|
|
|
|
|
16 |
def download_file(url, destination):
|
17 |
response = requests.get(url)
|
18 |
response.raise_for_status()
|
@@ -87,40 +89,18 @@ def convert_video(video_file, quality, aspect_ratio, video_url):
|
|
87 |
return output_files
|
88 |
|
89 |
# Change "video" to "file"
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
for path in output_paths:
|
95 |
-
video_path = f'http://localhost:5000/files/{path.name}'
|
96 |
-
video_component = f'''
|
97 |
-
<div style="margin-bottom: 20px; border: 1px solid #ccc; padding: 10px;">
|
98 |
-
<video controls>
|
99 |
-
<source src="{video_path}" type="application/x-mpegURL">
|
100 |
-
Your browser does not support the video tag.
|
101 |
-
</video>
|
102 |
-
<p>
|
103 |
-
<a href="{video_path}" target="_blank">Download {path.stem}</a>
|
104 |
-
</p>
|
105 |
-
<p>Resolution: {path.stem.split('_')[-1]}</p>
|
106 |
-
</div>
|
107 |
-
'''
|
108 |
-
html_blocks.append(video_component)
|
109 |
-
|
110 |
-
return html_string
|
111 |
-
|
112 |
video_file = components.File(type="video", label="Your video file")
|
113 |
-
quality = components.Radio(["Low", "Medium", "High"], label="Quality", default="High")
|
114 |
-
aspect_ratio = components.Radio(["16:9", "4:3", "1:1"], label="Aspect Ratio", default="16:9")
|
115 |
-
video_url = components.Textbox(placeholder="or paste video url here", label="Video URL")
|
116 |
|
117 |
interface = gr.Interface(
|
118 |
fn=convert_video,
|
119 |
inputs=[video_file, quality, aspect_ratio, video_url],
|
120 |
-
outputs=gr.outputs.
|
121 |
title="Video Converter",
|
122 |
description="A simple video converter app",
|
123 |
-
allow_flagging=False
|
124 |
)
|
125 |
|
126 |
interface.launch(server_name="0.0.0.0", server_port=7860)
|
|
|
13 |
|
14 |
logging.basicConfig(level=logging.INFO)
|
15 |
|
16 |
+
standard_resolutions = [240, 360, 480, 720, 1080, 1440, 2160, 4320]
|
17 |
+
|
18 |
def download_file(url, destination):
|
19 |
response = requests.get(url)
|
20 |
response.raise_for_status()
|
|
|
89 |
return output_files
|
90 |
|
91 |
# Change "video" to "file"
|
92 |
+
quality = gr.inputs.Radio(["Low", "Medium", "High"], label="Quality", default="High")
|
93 |
+
aspect_ratio = gr.inputs.Radio(["16:9", "4:3", "1:1"], label="Aspect Ratio", default="16:9")
|
94 |
+
video_url = gr.inputs.Textbox(placeholder="or paste video url here", label="Video URL")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
video_file = components.File(type="video", label="Your video file")
|
|
|
|
|
|
|
96 |
|
97 |
interface = gr.Interface(
|
98 |
fn=convert_video,
|
99 |
inputs=[video_file, quality, aspect_ratio, video_url],
|
100 |
+
outputs=gr.outputs.Textbox(label="Paths to Output Files"),
|
101 |
title="Video Converter",
|
102 |
description="A simple video converter app",
|
103 |
+
allow_flagging=False
|
104 |
)
|
105 |
|
106 |
interface.launch(server_name="0.0.0.0", server_port=7860)
|