def save_video_frame(
    video: VideoFile,
    frame: int,
    output: str,
    format: str = "jpg",
) -> ImageFile:
    """
    Saves video frame as a new image file. If output is a remote path,
    the image file will be uploaded to the remote storage.

    Args:
        video (VideoFile): Video file object.
        frame (int): Frame index.
        output (str): Output path, can be a local path or a remote path.
        format (str): Image format (default: 'jpg').

    Returns:
        ImageFile: Image file model.
    """
    img = video_frame_bytes(video, frame, format=format)
    output_file = posixpath.join(
        output, f"{video.get_file_stem()}_{frame:04d}.{format}"
    )
    return ImageFile.upload(img, output_file, catalog=video._catalog)

    Saves video frame as a new image file. If output is a remote path,
    the image file will be uploaded to the remote storage.

    Args:
        video (VideoFile): Video file object.
        frame (int): Frame index.
        output (str): Output path, can be a local path or a remote path.
        format (str): Image format (default: 'jpg').

    Returns:
        ImageFile: Image file model.
    
src/datachain/lib/video.py