macOS에서 소스에서 FFmpeg 빌드하기

이 페이지에서는 macOS에서 FFmpeg를 구성하고 빌드하는 방법을 설명합니다. 여기에는 다음이 포함됩니다:

  • FFmpeg 소스 코드를 가져옵니다.
  • 필요한 종속성을 설치합니다.
  • 명령줄에서 FFmpeg를 구성합니다.
  • 개발 라이브러리를 빌드합니다.

FFmpeg 소스 코드 가져오기

다음과 같은 방법으로 FFmpeg 소스 코드를 얻을 수 있습니다:

  • FFmpeg 다운로드 페이지에서 다운로드합니다.
  • git에서 복제. 예를 들어, 이 명령은 FFmpeg 소스 버전 7.1을 ~/ffmpeg 에 복제합니다.
    % git clone --branch n7.1 https://git.ffmpeg.org/ffmpeg.git ffmpeg

Qt Multimedia 메인 페이지에 설명된 것과 동일한 FFmpeg 버전을 사용하는 것이 좋습니다.

다음 단락에서는 FFmpeg 소스 코드를 ~/ffmpeg 에 저장한다고 가정합니다.

전제 조건

FFmpeg를 빌드하려면 다음 도구와 패키지가 필요합니다:

Homebrew 설치하기

Homebrew를 설치하려면 다음을 실행합니다:

% /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

홈브루 패키지 설치하기

홈브루 패키지 Yasm을 설치하려면 다음을 실행합니다:

% brew install yasm

FFmpeg 구성 및 빌드하기

~/ffmpeg 디렉터리 내에 build 디렉터리를 생성하고 그 안으로 이동합니다:

% mkdir ~/ffmpeg/build
% cd ~/ffmpeg/build

FFmpeg를 구성하려면, 실행합니다:

% ../configure --prefix=/usr/local/ffmpeg --disable-doc --enable-network --enable-shared

--prefix 인수는 빌드 후 FFmpeg 개발 라이브러리가 설치되는 경로를 지정합니다. 설명서가 필요하지는 않지만 네트워크 기능이 활성화되어 있어야 합니다. FFmpeg를 정적 라이브러리로 빌드하려면 --enable-shared 옵션을 생략하세요.

이전 코드 스니펫에서는 의도적으로 --prefix 인자에 절대 경로를 사용했습니다. 상대 경로(예: ../install)를 지정하면 종속성은 @rpath 을 사용하는 올바른 경로가 아닌 이 상대 경로를 사용하여 참조됩니다. 절대 경로를 사용하면 FFmpeg 빌드를 이식할 수 없습니다. 상대 경로를 사용하고 FFmpeg 빌드를 이식 가능하게 만들려면 otool을 사용하여 종속성을 수동으로 수정해야 합니다.

configure 명령이 완료되면 make 명령을 사용하여 FFmpeg를 빌드하고 설치합니다.

% make -j install

빌드가 오류 없이 완료되면 /usr/local/ffmpeg 디렉터리에 FFmpeg 개발 라이브러리가 설치됩니다. Qt Multimedia 을 빌드하는 경우 이 경로는 Qt Multimedia 을 구성할 때 사용되는 FFMPEG_DIR 변수에 저장됩니다.

FFmpeg 유니버설 바이너리 구성 및 빌드하기

macOS에서 유니버설 바이너리를 생성하려면(예: x86_64 및 arm64 아키텍처 모두용) 다음 단계를 따르세요:

  • arm64 아키텍처용 FFmpeg 구성 및 빌드:
    % ../configure --prefix=/usr/local/ffmpeg/arm64 --disable-doc --enable-network \
        --enable-shared --enable-cross-compile --arch=arm64 --cc="clang -arch arm64"
    % make -j install
  • x86_64 아키텍처용 FFmpeg 구성 및 빌드하기:
    % ../configure --prefix=/usr/local/ffmpeg/x86_64 --disable-doc --enable-network \
        --enable-shared --enable-cross-compile --arch=x86_64 --cc="clang -arch x86_64"
    % make -j install
  • 리포를 사용하여 빌드를 유니버설 바이너리로 결합합니다.

© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.