def _format_video_shape(video, time_compress=4, spatial_compress=8):
    """Prepare video for VAE"""
    time = video.shape[1]
    height = video.shape[2]
    width = video.shape[3]
    new_time = (
        (time - (time - 1) % time_compress) if (time - 1) % time_compress != 0 else time
    )
    new_height = (
        (height - (height) % spatial_compress)
        if height % spatial_compress != 0
        else height
    )
    new_width = (
        (width - (width) % spatial_compress) if width % spatial_compress != 0 else width
    )
    return video[:, :new_time, :new_height, :new_width]
Prepare video for VAE
opensora/models/causalvideovae/dataset/video_dataset.py