def extract_sound(
    vid_input: str,
    output_temp_dir: str = TEMP_VIDEO_FRAMES_DIR,
):
    """
    Extract audio from a video file and save it as a separate sound file. This needs FFmpeg installed.
    """
    if Path(vid_input).suffix == ".gif":
        print("Sound extracting process has passed because gif has no sound")
        return None

    os.makedirs(output_temp_dir, exist_ok=True)
    output_path = os.path.join(output_temp_dir, "sound.mp3")

    command = [
        'ffmpeg',
        '-loglevel', 'error',
        '-y',  # Enable overwriting
        '-i', vid_input,
        '-vn',
        output_path
    ]

    try:
        subprocess.run(command, check=True)
    except subprocess.CalledProcessError as e:
        print(f"Warning: Failed to extract sound from the video: {e}")

    return output_path

    Extract audio from a video file and save it as a separate sound file. This needs FFmpeg installed.
    
modules/utils/video_helper.py