def rescale_video_by_path(path: str, height: int, width: int):
    """
    Rescales an MP4 video (without audio) to the specified height and width.

    Args:
        path (str): The file path of the video.
        height (int): The target height of the video.
        width (int): The target width of the video.
    """
    try:
        # Read video and metadata
        video, info = read_video(path, backend="av")

        # Check if video is valid
        if video is None or video.size(0) == 0:
            raise ValueError("The video is invalid or empty.")

        # Resize video frames using a performant method
        resize_transform = transforms.Compose([transforms.Resize((width, height))])
        resized_video = torch.stack([resize_transform(frame) for frame in video])

        # Save resized video back to the original path
        resized_video = resized_video.permute(0, 2, 3, 1)
        write_video(path, resized_video, fps=int(info["video_fps"]), video_codec="h264")
    except Exception as e:
        print(f"Error rescaling video: {e}")

    Rescales an MP4 video (without audio) to the specified height and width.

    Args:
        path (str): The file path of the video.
        height (int): The target height of the video.
        width (int): The target width of the video.
    
opensora/datasets/utils.py