Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -83,30 +83,30 @@ def convert_video(video_file, quality, aspect_ratio, video_url):
|
|
| 83 |
|
| 84 |
output_paths = [] # Define output_paths as an empty list
|
| 85 |
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
|
| 91 |
-
|
| 92 |
-
|
| 93 |
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
|
| 101 |
-
|
| 102 |
-
|
| 103 |
|
| 104 |
-
|
| 105 |
|
| 106 |
-
|
| 107 |
-
|
| 108 |
|
| 109 |
-
|
| 110 |
|
| 111 |
video_file = gr.File(label="Video File")
|
| 112 |
quality = gr.Dropdown(
|
|
|
|
| 83 |
|
| 84 |
output_paths = [] # Define output_paths as an empty list
|
| 85 |
|
| 86 |
+
for res in standard_resolutions:
|
| 87 |
+
# Skip if resolution is higher than original
|
| 88 |
+
if res > original_height:
|
| 89 |
+
continue
|
| 90 |
|
| 91 |
+
scale = "-1:" + str(res) # we scale the height to res and keep aspect ratio
|
| 92 |
+
output_path = get_output_path(input_path, temp_dir, str(res) + 'p') # pass the resolution to create a unique output file
|
| 93 |
|
| 94 |
+
ffmpeg_command = [
|
| 95 |
+
"ffmpeg", "-i", str(input_path), "-c:v", "libx264", "-crf", str(quality),
|
| 96 |
+
"-vf", f"scale={scale}:force_original_aspect_ratio=decrease,pad=ceil(iw/2)*2:ceil(ih/2)*2",
|
| 97 |
+
"-hls_time", "10", "-hls_playlist_type", "vod", "-hls_segment_filename",
|
| 98 |
+
str(temp_dir / f"{output_path.stem}_%03d.ts"), str(output_path)
|
| 99 |
+
]
|
| 100 |
|
| 101 |
+
logging.info("Running ffmpeg command: " + ' '.join(ffmpeg_command))
|
| 102 |
+
subprocess.run(ffmpeg_command, check=True)
|
| 103 |
|
| 104 |
+
output_paths.append(output_path) # Append each completed output file to the output_paths list
|
| 105 |
|
| 106 |
+
master_playlist_path = create_master_playlist(output_paths, temp_dir)
|
| 107 |
+
output_paths.append(master_playlist_path)
|
| 108 |
|
| 109 |
+
return output_paths # Return the list of completed output files
|
| 110 |
|
| 111 |
video_file = gr.File(label="Video File")
|
| 112 |
quality = gr.Dropdown(
|