2024년 2월 1일 목요일

윈도우에서 ffmpeg NVIDIA CUDA Codec 연동 build

 * msys 설치



* Visual Studio 메뉴에서 x64 Native Tools Command Prompt for VS 2022 실행

c:\msys64\msys2_shell.cmd -use-full-path 실행

빌드에 필요한 패키지들을 설치한다.

pacman -Syu
pacman -S make diffutils yasm nasm git pkg-config

where link 하면 아래 두개가 나온다.

C:\msys64\usr\bin\link.exe
C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\<버전>\bin\Hostx64\x64\link.exe

mv /usr/bin/link.exe /usr/bin/link.exe.org => 겹치지 않게 이름 변경


* 소스 다운로드

git clone https://git.videolan.org/git/ffmpeg/nv-codec-headers.git

nv-codec-headers 폴더 들어가서 아래 실행
make install PREFIX=/usr

ffmpeg 소스 다운로드
git clone https://git.ffmpeg.org/ffmpeg.git


* CUDA Toolkit 설치
https://developer.nvidia.com/cuda-toolkit 에서 툴킷 받아서 설치한다.(혹은 구글에서 cuda toolkit 검색)

홈 디렉토리에서 아래 폴더 생성
mkdir build
mkdir nv_sdk

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\<버전> 아래에 include 폴더 복사 후 nv_sdk 아래에 불여넣기
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\<버전>\lib 아래에 x64 폴더 복사 후 nv_sdk 아래에 붙여넣기


* 빌드

export PATH="/c/Program Files/NVIDIA GPU Computing Toolkit/CUDA/<버전>/bin/":$PATH

ffmpeg 폴더에 들어가서 아래 실행

./configure --prefix=../build --toolchain=msvc --arch=x86_64 --enable-yasm --enable-shared --enable-gpl --enable-nonfree --enable-w32threads --enable-cuda-nvcc --enable-libnpp --extra-cflags=-I../nv_sdk/include --extra-ldflags=-libpath:../nv_sdk/x64

make
make install



* 32비트 빌드

Visual Studio 메뉴에서 x86 Native Tools Command Prompt for VS 2022 실행 후 c:\msys64\msys2_shell.cmd -use-full-path 실행

./configure --prefix=../build --toolchain=msvc --arch=x86_32 --enable-yasm --enable-shared --enable-gpl --enable-nonfree --enable-w32threads

* x264 빌드 후 ffmpeg 연동 빌드

32/64 비트는 각각 
32비트 => x86 Native Tools Command Prompt for VS 2022 실행 후 c:\msys64\msys2_shell.cmd -use-full-path 실행
64비트 => x64 Native Tools Command Prompt for VS 2022 실행 후 c:\msys64\msys2_shell.cmd -use-full-path 실행

소스 다운로드
git clone http://git.videolan.org/git/x264.git

x264 폴더에서 아래 실행 - 32/64비트 공통
CC=cl ./configure --prefix=../build --enable-static
 
make
make install

export PKG_CONFIG_PATH=../build/lib/pkgconfig/

ffmpeg 폴더에서 아래 실행
64비트
./configure --prefix=../build --toolchain=msvc --arch=x86_64 --enable-yasm --enable-shared --enable-gpl --enable-nonfree --enable-w32threads --enable-cuda-nvcc --enable-libnpp --extra-cflags="-I../nv_sdk/include -I../build/include" --extra-ldflags="-libpath:../nv_sdk/x64 -libpath:../build/lib" --enable-libx264

32비트
./configure --prefix=../build --toolchain=msvc --arch=x86_32 --enable-yasm --enable-shared --enable-gpl --enable-nonfree --enable-w32threads  --extra-cflags="-I../build/include" --extra-ldflags="-libpath:../build/lib" --enable-libx264

make
make install

댓글 없음:

댓글 쓰기