def extract_frames(
    vid_input: str,
    output_temp_dir: str = TEMP_VIDEO_FRAMES_DIR,
    start_number: int = 0,
    clean=True
):
    """
    Extract frames as jpg files and save them into output_temp_dir. This needs FFmpeg installed.
    """
    if clean:
        clean_temp_dir(temp_dir=output_temp_dir)

    os.makedirs(output_temp_dir, exist_ok=True)
    output_path = os.path.join(output_temp_dir, "%05d.jpg")

    command = [
        'ffmpeg',
        '-loglevel', 'error',
        '-y',  # Enable overwriting
        '-i', vid_input,
        '-qscale:v', '2',
        '-vf', f'scale=iw:ih',
        '-start_number', str(start_number),
        f'{output_path}'
    ]

    try:
        subprocess.run(command, check=True)
        print(f"Video frames extracted to \"{os.path.normpath(output_temp_dir)}\"")
    except subprocess.CalledProcessError as e:
        print("Error occurred while extracting frames from the video")
        raise RuntimeError(f"An error occurred: {str(e)}")

    return get_frames_from_dir(output_temp_dir)

    Extract frames as jpg files and save them into output_temp_dir. This needs FFmpeg installed.
    
modules/utils/video_helper.py