litellm / services /whisper /utils /vertical.py
Ava2lon's picture
Upload 205 files
1425afc verified
Raw
History Blame Contribute Delete
452 Bytes
from moviepy.editor import VideoFileClip
def vertical_crop(video_path):
clip = VideoFileClip(video_path)
w, h = clip.size
target_ratio = 9 / 16
new_width = int(h * target_ratio)
x_center = w / 2
cropped = clip.crop(
x_center=x_center,
width=new_width,
height=h
)
output = video_path.replace(".mp4", "_vertical.mp4")
cropped.write_videofile(output, codec="libx264")
return output