Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -32,7 +32,7 @@ fs = s3fs.S3FileSystem(anon=False, client_kwargs={'region_name': 'us-east-1'})
|
|
32 |
|
33 |
logging.basicConfig(level=logging.INFO)
|
34 |
|
35 |
-
standard_resolutions = [
|
36 |
|
37 |
def start_http_server(port=8000):
|
38 |
handler = http.server.SimpleHTTPRequestHandler
|
@@ -109,14 +109,18 @@ def convert_video(video_file, quality, aspect_ratio, video_url):
|
|
109 |
# Get the original height to avoid upscaling
|
110 |
original_height = video.size[1]
|
111 |
|
|
|
|
|
|
|
112 |
output_paths = []
|
113 |
-
for res in standard_resolutions:
|
114 |
if res > original_height:
|
115 |
continue
|
116 |
|
117 |
scale = "-1:" + str(res)
|
118 |
output_path = get_output_path(input_path, str(res) + 'p')
|
119 |
|
|
|
120 |
ffmpeg_command = [
|
121 |
"ffmpeg", "-i", str(input_path), "-c:v", "libx264", "-crf", str(quality),
|
122 |
"-vf", f"scale={scale}:force_original_aspect_ratio=decrease,pad=ceil(iw/2)*2:ceil(ih/2)*2",
|
@@ -147,7 +151,7 @@ def convert_video(video_file, quality, aspect_ratio, video_url):
|
|
147 |
return output_html
|
148 |
|
149 |
video_file = gr.inputs.File(label="Your video file")
|
150 |
-
quality = gr.inputs.Slider(minimum=
|
151 |
aspect_ratio = gr.inputs.Dropdown(["16:9", "4:3", "1:1", "3:4", "9:16", "1:1", "2:1", "1:2"], label="Aspect Ratio", default="16:9")
|
152 |
video_url = gr.inputs.Textbox(lines=1, placeholder="or paste video url here", label="Video URL")
|
153 |
|
|
|
32 |
|
33 |
logging.basicConfig(level=logging.INFO)
|
34 |
|
35 |
+
standard_resolutions = [4320, 2160, 1440, 1080, 720, 480, 360, 240]
|
36 |
|
37 |
def start_http_server(port=8000):
|
38 |
handler = http.server.SimpleHTTPRequestHandler
|
|
|
109 |
# Get the original height to avoid upscaling
|
110 |
original_height = video.size[1]
|
111 |
|
112 |
+
# Get the original height to avoid upscaling
|
113 |
+
original_height = video.size[1]
|
114 |
+
|
115 |
output_paths = []
|
116 |
+
for res in reversed(standard_resolutions):
|
117 |
if res > original_height:
|
118 |
continue
|
119 |
|
120 |
scale = "-1:" + str(res)
|
121 |
output_path = get_output_path(input_path, str(res) + 'p')
|
122 |
|
123 |
+
# use a lower CRF value for better quality
|
124 |
ffmpeg_command = [
|
125 |
"ffmpeg", "-i", str(input_path), "-c:v", "libx264", "-crf", str(quality),
|
126 |
"-vf", f"scale={scale}:force_original_aspect_ratio=decrease,pad=ceil(iw/2)*2:ceil(ih/2)*2",
|
|
|
151 |
return output_html
|
152 |
|
153 |
video_file = gr.inputs.File(label="Your video file")
|
154 |
+
quality = gr.inputs.Slider(minimum=0, maximum=51, default=23, label="Quality (0: Highest Quality - 51: Fastest)")
|
155 |
aspect_ratio = gr.inputs.Dropdown(["16:9", "4:3", "1:1", "3:4", "9:16", "1:1", "2:1", "1:2"], label="Aspect Ratio", default="16:9")
|
156 |
video_url = gr.inputs.Textbox(lines=1, placeholder="or paste video url here", label="Video URL")
|
157 |
|