Whisper / utils /vertical.py
basyx's picture
Create vertical.py
27e5f8a verified
Raw
History Blame
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