Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -85,14 +85,17 @@ def convert_video(video_file, quality, aspect_ratio, video_url):
|
|
85 |
return output_path
|
86 |
else:
|
87 |
# The file does not exist, so we need to convert it
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
|
|
|
|
|
|
96 |
except subprocess.TimeoutExpired:
|
97 |
print("ffmpeg timed out")
|
98 |
return "ffmpeg command timed out."
|
|
|
85 |
return output_path
|
86 |
else:
|
87 |
# The file does not exist, so we need to convert it
|
88 |
+
if aspect_ratio is None:
|
89 |
+
video = VideoFileClip(input_path)
|
90 |
+
aspect_ratio = f"{video.size[0]}:{video.size[1]}"
|
91 |
+
|
92 |
+
ffmpeg_command = f"ffmpeg -i {input_path} -c:v libx264 -crf {quality} -vf scale=-1:720,setsar={aspect_ratio} -hls_time 6 -hls_playlist_type vod -f hls {output_path}"
|
93 |
+
|
94 |
+
print(f"Input Path: {input_path}")
|
95 |
+
print(f"Output Path: {output_path}")
|
96 |
+
|
97 |
+
try:
|
98 |
+
subprocess.run(ffmpeg_command, shell=True, timeout=600)
|
99 |
except subprocess.TimeoutExpired:
|
100 |
print("ffmpeg timed out")
|
101 |
return "ffmpeg command timed out."
|