Spaces:
Running on Zero
Running on Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -302,11 +302,13 @@ def generate_video(
|
|
| 302 |
tgt_aspect = target_w / target_h
|
| 303 |
if src_aspect > tgt_aspect:
|
| 304 |
content_h = int(round(target_w / src_aspect))
|
|
|
|
| 305 |
if 0 < content_h < hdr_video.shape[1]:
|
| 306 |
print(f"[HDR] Cropping reflected bottom: {hdr_video.shape[1]} -> {content_h}")
|
| 307 |
hdr_video = hdr_video[:, :content_h, :, :]
|
| 308 |
elif src_aspect < tgt_aspect:
|
| 309 |
content_w = int(round(target_h * src_aspect))
|
|
|
|
| 310 |
if 0 < content_w < hdr_video.shape[2]:
|
| 311 |
print(f"[HDR] Cropping reflected right: {hdr_video.shape[2]} -> {content_w}")
|
| 312 |
hdr_video = hdr_video[:, :, :content_w, :]
|
|
|
|
| 302 |
tgt_aspect = target_w / target_h
|
| 303 |
if src_aspect > tgt_aspect:
|
| 304 |
content_h = int(round(target_w / src_aspect))
|
| 305 |
+
content_h -= content_h % 2 # libx264 yuv420p needs even dims
|
| 306 |
if 0 < content_h < hdr_video.shape[1]:
|
| 307 |
print(f"[HDR] Cropping reflected bottom: {hdr_video.shape[1]} -> {content_h}")
|
| 308 |
hdr_video = hdr_video[:, :content_h, :, :]
|
| 309 |
elif src_aspect < tgt_aspect:
|
| 310 |
content_w = int(round(target_h * src_aspect))
|
| 311 |
+
content_w -= content_w % 2 # libx264 yuv420p needs even dims
|
| 312 |
if 0 < content_w < hdr_video.shape[2]:
|
| 313 |
print(f"[HDR] Cropping reflected right: {hdr_video.shape[2]} -> {content_w}")
|
| 314 |
hdr_video = hdr_video[:, :, :content_w, :]
|