libde265 설치 방법, h.265 인코더 디코더 라이브러리 컴파일

Estimated read time 5 min read

본 블로그 포스트에서는 libde265 설치 방법을 다룹니다. libde265 라이브러리는 h.265 동영상 코덱오픈 소스 구현체1이며, 프로젝트 리포지토리2로 부터 소스코드를 다운로드 후, 컴파일 과정을 거쳐 라이브러리 형태의 h265 코덱 설치 까지 과정을 다룹니다.


libde265 설치 방법 소개에 앞서

libde265 라이브러리?

libde265h.265 동영상 코덱오픈 소스 구현체입니다. 이 라이브러리는 처음부터 새로 개발되었으며, 다른 소프트웨어에 쉽게 통합할 수 있도록 일반적인 C API를 제공합니다. libde265는 WPP와 타일 기반 멀티스레딩을 지원하며, SSE 최적화도 포함하고 있습니다.

libde265 (https://www.libde265.org/)

이 디코더는 메인 프로파일의 모든 기능을 지원하며, 거의 모든 컴플라이언스 스트림을 올바르게 디코딩할 수 있습니다. 덕분에 다양한 환경에서 안정적이고 효율적으로 동작하며, 고품질의 동영상 재생을 가능하게 합니다. libde265는 높은 성능과 유연성을 바탕으로, 다양한 응용 프로그램에서 활용될 수 있습니다.

libde265 사용?

libde265 라이브러리는 h.265 동영상 코덱의 오픈 소스 구현체입니다. 웹 서비스나 서버사이드 소프트웨어에서 h.265 동영상을 처리해야 하는 경우 필요할 수 있으며, PHP에서 최신 웹 이미지 포맷 webp 및 avif 형식을 지원하기 위한 GD 설치 과정에서도 사용됩니다. webp 및 avif 이미지 포맷 관련 포스트는 Nginx webp, avif 파일 캐시 적용 포스트나 아래 글 목록을 확인하세요.


libde265 설치 방법

libde265 다운로드

wget 명령으로 libde265의 github 리포지토리3에서 소스코드를 다운로드 합니다. 포스트 작성일 기준, 최신 릴리즈 버젼은 v1.0.15 이며, libde265의 github 릴리즈 페이지4에서 다운로드 할 수 있습니다. 버젼 넘버와 함께 릴리즈 페이지에 공개된 파일이 아닌, git 명령으로 리포지토리의 가장 최신 파일을 checkout 이나 clone 하는 방법은 설치 과정에서 오류 발생 소지가 있으므로, 본 포스트에서는 추천하지 않습니다.

$ wget https://github.com/strukturag/libde265/releases/download/v1.0.15/libde265-1.0.15.tar.gz                                                                                            
                                                                                            
$ ls -al libde265-1.0.15.tar.gz                                                                                            
-rw-r--r--. 1 ec2-user ec2-user 846016 12월 20  2023 libde265-1.0.15.tar.gz                                                                                            

libde265 파일(libde265-1.0.15.tar.gz)이 정상 다운로드 된 것을 확인한 후, tar 명령으로 파일의 압축을 풀어줍니다.

$ tar xzvf libde265-1.0.15.tar.gz                                                                                            
libde265-1.0.15/                                                                                            
libde265-1.0.15/INSTALL                                                                                                                                                                                                                                                                                      libde265-1.0.15/libde265.png                                                                                            
libde265-1.0.15/autogen.sh                                                                                            
libde265-1.0.15/extra/                                                                                            
libde265-1.0.15/extra/getopt.c                                                                                            
libde265-1.0.15/extra/win32cond.h                                                                                            
libde265-1.0.15/extra/getopt.h                                                                                            
libde265-1.0.15/extra/getopt_long.c                                                                                            
libde265-1.0.15/extra/win32cond.c                                                                                            
libde265-1.0.15/build.bat<br>libde265-1.0.15/configure                                                                                            
libde265-1.0.15/README<br>libde265-1.0.15/Makefile.in                                                                                            
:                                                                                            
libde265-1.0.15/dec265/                                                                                            
libde265-1.0.15/dec265/Makefile.in                                                                                            
libde265-1.0.15/dec265/Makefile.vc7                                                                                            
libde265-1.0.15/dec265/Makefile.am                                                                                            
libde265-1.0.15/dec265/dec265.cc                                                                                            
libde265-1.0.15/dec265/CMakeLists.txt                                                                                            
libde265-1.0.15/dec265/sdl.cc                                                                                            
libde265-1.0.15/dec265/sdl.hh                                                                                            
libde265-1.0.15/dec265/COPYING                                                                                            
libde265-1.0.15/ltmain.sh                                                                                            
libde265-1.0.15/ChangeLog                                                                                            
libde265-1.0.15/COPYING                                                                                            

설정 파일 생성

libde265 리포의 README.md 소개글을 보면 라이브러리 소스코드와 함께 예제 실행 파일 두 개가 포함되어 있습니다. 하지만, 해당 파일은 사용하지 않을 것 이므로 함께 컴파일하지 않도록 제외하는 옵션을 적용합니다.

The library comes with two example programs:

dec265, a simple player for raw h.265 bitstreams. It serves nicely as an example program how to use libde265.

sherlock265, a Qt-based video player with the additional capability to overlay some graphical representations of the h.265 bitstream (like CU-trees, intra-prediction modes).

:

You can disable building of the example programs by running ./configure with

  --disable-dec265        Do not build the dec265 decoder program.
  --disable-sherlock265   Do not build the sherlock265 visual inspection program.

두 옵션(--disable-dec265, --disable-sherlock265) 함께 사용하여 configure 명령을 실행합니다.

$ ./configure --disable-dec265 --disable-sherlock265                                                                                            
checking build system type... aarch64-unknown-linux-gnu                                                                                            
checking host system type... aarch64-unknown-linux-gnu                                                                                                                                                           checking target system type... aarch64-unknown-linux-gnu                                                                                                                                                         checking how to print strings... printf                                                                                                                                                                          checking for gcc... gcc                                                                                                                                                                                          checking whether the C compiler works... yes                                                                                                                                                                     checking for C compiler default output file name... a.out                                   
:                                                                                           
configure: ---------------------------------------                                                                                                                                                               configure: Building dec265 example: no                                                                                                                                                                           configure: Building sherlock265 example: no                                                                                                                                                                      configure: Building encoder: no                                                                                                                                                                                  configure: ---------------------------------------                                                                                                                                                               checking that generated files are newer than configure... done                                                                                                                                                   configure: creating ./config.status                                                                                                                                                                              config.status: creating Makefile                                                                                                                                                                                 config.status: creating libde265/Makefile                                                                                                                                                                        config.status: creating libde265/arm/Makefile                                                                                                                                                                    config.status: creating libde265/x86/Makefile                                                                                                                                                                    config.status: creating libde265/encoder/Makefile                                                                                                                                                                config.status: creating libde265/encoder/algo/Makefile                                                                                                                                                           config.status: creating libde265/de265-version.h                                                                                                                                                                 config.status: creating dec265/Makefile                                                                                                                                                                          config.status: creating enc265/Makefile                                                                                                                                                                          config.status: creating sherlock265/Makefile                                                                                                                                                                     config.status: creating tools/Makefile                                                                                                                                                                           config.status: creating acceleration-speed/Makefile                                         
config.status: creating libde265.pc                                                         
config.status: creating config.h                                                                                                                                                                                 config.status: executing libtool commands                                                                                                                                                                        config.status: executing depfiles commands                                                                                            

컴파일 준비

configure 명령이 정상적으로 종료되었으면, cmake를 사용해 빌드에 필요한 파일을 생성합니다. build 라는 별도 디렉토리 안에서 모든 작업이 이뤄지도록 (mkdir buid && cd build) 디렉토리를 생성 후 진행합니다. -B . 는 빌드 디렉토리 경로를 현재 디렉토리로, -S .. 는 소스 파일의 위치를 상위 디렉토리로 명시적으로 지정하는 옵션입니다.

$ mkdir build && cd build                                                                   
$ cmake -B . -S ..                                                                          
-- The C compiler identification is GNU 11.4.1                                                                                                                                                               
-- The CXX compiler identification is GNU 11.4.1                                                                                            
-- Detecting C compiler ABI info                                                                                            
-- Detecting C compiler ABI info - done                                                                                            
-- Check for working C compiler: /usr/bin/cc - skipped                                                                                            
-- Detecting C compile features                                                                                            
-- Detecting C compile features - done                                                                                            
-- Detecting CXX compiler ABI info                                                                                            
-- Detecting CXX compiler ABI info - done                                                                                            
-- Check for working CXX compiler: /usr/bin/c++ - skipped                                                                                            
-- Detecting CXX compile features                                                                                            
-- Detecting CXX compile features - done                                                                                            
CMake Warning at CMakeLists.txt:26 (find_package):                                                                                            
  By not providing "FindSDL2.cmake" in CMAKE_MODULE_PATH this project has                                                                                            
  asked CMake to find a package configuration file provided by "SDL2", but                                                                                            
  CMake did not find one.                                                                                            
                                                                                            
  Could not find a package configuration file provided by "SDL2" with any of                                                                                            
  the following names:                                                                                            
                                                                                            
    SDL2Config.cmake                                                                                            
    sdl2-config.cmake                                                                                            
                                                                                            
  Add the installation prefix of "SDL2" to CMAKE_PREFIX_PATH or set                                                                                            
  "SDL2_DIR" to a directory containing one of the above files.  If "SDL2"                                                                                            
  provides a separate development package or SDK, be sure it has been                                                                                            
  installed.                                                                                            
                                                                                            
                                                                                            
-- Looking for pthread.h                                                                          
-- Looking for pthread.h - found                                                                          
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD                                                                          
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success                                                                          
-- Found Threads: TRUE                                                                          
-- Looking for malloc.h                                                                          
-- Looking for malloc.h - found                                                                          
-- Looking for posix_memalign                                                                          
-- Looking for posix_memalign - found                                                                          
-- Looking for _LIBCPP_VERSION                                                                          
-- Looking for _LIBCPP_VERSION - not found                                                                          
-- Performing Test HAVE_X86                                                                          
-- Performing Test HAVE_X86 - Failed                                                                          
-- Configuring done                                                                          
-- Generating done                                                                          
-- Build files have been written to: ../../libde265-1.0.15/build                                                                   

컴파일을 위한 설정이 현재 디렉토리에 생성되었습니다. 중간에 SDL2와 관련된 파일과 경로를 찾을 수 없다는 메시지가 나오지만, 현재 설치하는 libde265 라이브러리에 포함하지 않을 것 이므로 무시하고 계속 진행합니다.

라이브러리 컴파일

configurecmake가 정상적으로 실행되었다면 컴파일을 위한 준비를 마쳤습니다. 이제 make 명령으로 컴파일을 진행합니다.

$ make<br>[ 96%] Linking CXX shared library libde265.so<br>[ 96%] Built target de265<br>[ 98%] Building CXX object dec265/CMakeFiles/dec265.dir/dec265.cc.o<br>[100%] Linking CXX executable dec265<br>[100%] Built target dec265

컴파일 과정에서 각종 문법 및 객체 미사용 등의 warning 메시지가 출력 될 수 있으나, 무시하고 최종적으로 라이브러리 파일(libde265.so)이 정상적으로 생성되었는지 확인합니다.

$ ll libde265/<br>합계 2700<br>drwxr-xr-x. 4 ec2-user ec2-user      98  7월 16 10:56 CMakeFiles<br>-rw-r--r--. 1 ec2-user ec2-user   38309  7월 16 10:56 Makefile<br>-rw-r--r--. 1 ec2-user ec2-user    4759  7월 16 10:56 cmake_install.cmake<br>-rw-r--r--. 1 ec2-user ec2-user    1122  7월 16 10:56 de265-version.h<br>drwxr-xr-x. 4 ec2-user ec2-user      79  7월 16 10:56 encoder<br>-rw-r--r--. 1 ec2-user ec2-user     295  7월 16 10:56 libde265.pc<br>-rwxr-xr-x. 1 ec2-user ec2-user 2745856  7월 16 11:02 libde265.so<br>-rw-r--r--. 1 ec2-user ec2-user    3368  7월 16 10:56 libde265ConfigVersion.cmake

libde265 설치 방법

시스템 공유 라이브러리 설치

동적 라이브러리 파일(libde265.so)이 정상 생성된 것을 확인했다면, sudocmake --install 명령으로 시스템 전역에서 사용할 수 있도록 컴파일 완료된 라이브러리 파일헤더 파일을 시스템에 설치합니다.

$ sudo cmake --install libde265<br>-- Install configuration: ""<br>-- Installing: /usr/local/lib64/libde265.so<br>-- Up-to-date: /usr/local/include/libde265/de265.h<br>-- Up-to-date: /usr/local/include/libde265/en265.h<br>-- Installing: /usr/local/include/libde265/de265-version.h<br>-- Installing: /usr/local/lib64/cmake/libde265/libde265Config.cmake<br>-- Installing: /usr/local/lib64/cmake/libde265/libde265Config-noconfig.cmake<br>-- Installing: /usr/local/lib64/cmake/libde265/libde265ConfigVersion.cmake<br>-- Installing: /usr/local/lib64/pkgconfig/libde265.pc

라이브러리 및 헤더 파일 설치 경로

최종적으로 설치된 동적 라이브러리 파일의 위치는 /usr/local/lib64/libde265.so 이며, 헤더 파일은 /usr/local/include/libde265/ 디렉토리에 위치해 있습니다. 추후 다른 라이브러리나 소프트웨어를 컴파일 할 경우, 필요에 따라 이 경로를 명시적으로 지정해야 할 수 있으므로 설치된 경로를 알아두는 것이 좋습니다.


요약

이번 포스트에서는 h.265 동영상 코덱오픈 소스 구현체libde265 라이브러리를 다운로드하고 소스코드 컴파일 후, 공유 라이브러리 형태로 시스템에 설치하는 법을 알아보았습니다.


참고자료 및 각주

  1. https://www.libde265.org/ ↩︎
  2. https://github.com/strukturag/libde265 ↩︎
  3. https://github.com/strukturag/libde265 ↩︎
  4. https://github.com/strukturag/libde265/releases ↩︎