TIMBOVILL commited on
Commit
73594ab
·
verified ·
1 Parent(s): 5e68066

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -8
app.py CHANGED
@@ -34,14 +34,14 @@ def process_video(text):
34
  start_time = random.uniform(0, max(0, video.duration - 60))
35
  video = video.subclip(start_time, min(start_time + 60, video.duration))
36
 
37
- def resize_image(image, new_size):
38
- pil_image = Image.fromarray(image)
39
- resized_pil = pil_image.resize(new_size[::-1], Image.LANCZOS)
40
- return np.array(resized_pil)
41
-
42
- new_size = (1080, int(video.h * (1080 / video.w)))
43
- video = video.fl_image(lambda image: resize_image(image, new_size))
44
- video = video.crop(x1=video.w // 2 - 540, x2=video.w // 2 + 540)
45
 
46
  text_lines = text.split()
47
  text = "\n".join([" ".join(text_lines[i:i+8]) for i in range(0, len(text_lines), 8)])
 
34
  start_time = random.uniform(0, max(0, video.duration - 60))
35
  video = video.subclip(start_time, min(start_time + 60, video.duration))
36
 
37
+ # Resize the video to have a width of 1080 while keeping the aspect ratio
38
+ new_width = 1080
39
+ new_height = int(video.h * (new_width / video.w))
40
+ video = video.resize(width=new_width)
41
+
42
+ # Crop the video to a 9:16 aspect ratio
43
+ target_height = 1920
44
+ video = video.crop(y_center=video.h / 2, height=target_height)
45
 
46
  text_lines = text.split()
47
  text = "\n".join([" ".join(text_lines[i:i+8]) for i in range(0, len(text_lines), 8)])