Build own FFMPEG

This commit is contained in:
Florian Märkl 2019-08-18 13:59:09 +02:00
commit 8fd2610941
No known key found for this signature in database
GPG key ID: 125BC8A5A6A1E857
4 changed files with 74 additions and 34 deletions

1
.gitignore vendored
View file

@ -5,3 +5,4 @@ cmake-build-*
.DS_store .DS_store
*.AppImage *.AppImage
appdir appdir
/ffmpeg*

View file

@ -19,10 +19,9 @@ matrix:
- qt512gamepad - qt512gamepad
- qt512svg - qt512svg
- libgl1-mesa-dev - libgl1-mesa-dev
- libavcodec-dev - nasm
- libavcodec-extra
env: env:
- CMAKE_PREFIX_PATH="/opt/qt512" - CMAKE_PREFIX_PATH="$TRAVIS_BUILD_DIR/ffmpeg-prefix;/opt/qt512"
- CMAKE_EXTRA_ARGS="-DCMAKE_INSTALL_PREFIX=/usr" - CMAKE_EXTRA_ARGS="-DCMAKE_INSTALL_PREFIX=/usr"
- DEPLOY_FILE="Chiaki-x86_64.AppImage" - DEPLOY_FILE="Chiaki-x86_64.AppImage"
after_success: after_success:
@ -42,12 +41,15 @@ matrix:
- qt - qt
- opus - opus
- openssl@1.1 - openssl@1.1
- ffmpeg - nasm
env: env:
- CMAKE_PREFIX_PATH="/usr/local/opt/openssl@1.1;/usr/local/opt/qt" - CMAKE_PREFIX_PATH="/usr/local/opt/openssl@1.1;/usr/local/opt/qt"
- CMAKE_EXTRA_ARGS="" - CMAKE_EXTRA_ARGS=""
- DEPLOY_FILE=""" - DEPLOY_FILE="""
install:
- scripts/build-ffmpeg.sh
script: script:
- mkdir build && cd build - mkdir build && cd build
- cmake - cmake

View file

@ -29,7 +29,19 @@ Note that only components requested with `COMPONENTS` or `OPTIONAL_COMPONENTS`
are guaranteed to set these variables or provide targets. are guaranteed to set these variables or provide targets.
#]==] #]==]
find_package(PkgConfig)
function (_ffmpeg_find component headername) function (_ffmpeg_find component headername)
# Try pkg-config first
if(PKG_CONFIG_FOUND)
pkg_check_modules(FFMPEG_${component} lib${component} IMPORTED_TARGET)
if(FFMPEG_${component}_FOUND)
set_target_properties(PkgConfig::FFMPEG_${component} PROPERTIES IMPORTED_GLOBAL TRUE)
add_library(FFMPEG::${component} ALIAS PkgConfig::FFMPEG_${component})
return()
endif()
endif()
find_path("FFMPEG_${component}_INCLUDE_DIR" find_path("FFMPEG_${component}_INCLUDE_DIR"
NAMES NAMES
"lib${component}/${headername}" "lib${component}/${headername}"
@ -130,23 +142,28 @@ function (_ffmpeg_find component headername)
endif () endif ()
endfunction () endfunction ()
unset(_pkg_config_extra_arg)
_ffmpeg_find(avutil avutil.h) _ffmpeg_find(avutil avutil.h)
_ffmpeg_find(avresample avresample.h #_ffmpeg_find(avresample avresample.h
avutil) # avutil)
_ffmpeg_find(swresample swresample.h _ffmpeg_find(swresample swresample.h
avutil) avutil)
_ffmpeg_find(swscale swscale.h _ffmpeg_find(swscale swscale.h
avutil) avutil)
_ffmpeg_find(avcodec avcodec.h _ffmpeg_find(avcodec avcodec.h
avutil) avutil)
_ffmpeg_find(avformat avformat.h #_ffmpeg_find(avformat avformat.h
avcodec avutil) # avcodec avutil)
_ffmpeg_find(avfilter avfilter.h #_ffmpeg_find(avfilter avfilter.h
avutil) # avutil)
_ffmpeg_find(avdevice avdevice.h #_ffmpeg_find(avdevice avdevice.h
avformat avutil) # avformat avutil)
if (TARGET FFMPEG::avutil) if (TARGET FFMPEG::avutil)
if(TARGET PkgConfig::FFMPEG_avutil)
set(FFMPEG_VERSION ${FFMPEG_avutil_VERSION})
else()
set(_ffmpeg_version_header_path "${FFMPEG_avutil_INCLUDE_DIR}/libavutil/ffversion.h") set(_ffmpeg_version_header_path "${FFMPEG_avutil_INCLUDE_DIR}/libavutil/ffversion.h")
if (EXISTS "${_ffmpeg_version_header_path}") if (EXISTS "${_ffmpeg_version_header_path}")
file(STRINGS "${_ffmpeg_version_header_path}" _ffmpeg_version file(STRINGS "${_ffmpeg_version_header_path}" _ffmpeg_version
@ -158,12 +175,19 @@ if (TARGET FFMPEG::avutil)
endif () endif ()
unset(_ffmpeg_version_header_path) unset(_ffmpeg_version_header_path)
endif() endif()
endif ()
set(FFMPEG_INCLUDE_DIRS) set(FFMPEG_INCLUDE_DIRS)
set(FFMPEG_LIBRARIES) set(FFMPEG_LIBRARIES)
set(_ffmpeg_required_vars) set(_ffmpeg_required_vars)
foreach (_ffmpeg_component IN LISTS FFMPEG_FIND_COMPONENTS) foreach (_ffmpeg_component IN LISTS FFMPEG_FIND_COMPONENTS)
if (TARGET "FFMPEG::${_ffmpeg_component}") if (TARGET "FFMPEG::${_ffmpeg_component}")
if(TARGET PkgConfig::FFMPEG_${_ffmpeg_component})
list(APPEND FFMPEG_INCLUDE_DIRS ${FFMPEG_${_ffmpeg_component}_INCLUDE_DIRS})
list(APPEND FFMPEG_LIBRARIES ${FFMPEG_${_ffmpeg_component}_LIBRARIES})
list(APPEND _ffmpeg_required_vars
"FFMPEG_${_ffmpeg_component}_LIBRARIES")
else()
set(FFMPEG_${_ffmpeg_component}_INCLUDE_DIRS set(FFMPEG_${_ffmpeg_component}_INCLUDE_DIRS
"${FFMPEG_${_ffmpeg_component}_INCLUDE_DIR}") "${FFMPEG_${_ffmpeg_component}_INCLUDE_DIR}")
set(FFMPEG_${_ffmpeg_component}_LIBRARIES set(FFMPEG_${_ffmpeg_component}_LIBRARIES
@ -174,8 +198,9 @@ foreach (_ffmpeg_component IN LISTS FFMPEG_FIND_COMPONENTS)
"${FFMPEG_${_ffmpeg_component}_LIBRARIES}") "${FFMPEG_${_ffmpeg_component}_LIBRARIES}")
if (FFMEG_FIND_REQUIRED_${_ffmpeg_component}) if (FFMEG_FIND_REQUIRED_${_ffmpeg_component})
list(APPEND _ffmpeg_required_vars list(APPEND _ffmpeg_required_vars
"FFMPEG_${_ffmpeg_required_vars}_INCLUDE_DIRS" "FFMPEG_${_ffmpeg_component}_INCLUDE_DIRS"
"FFMPEG_${_ffmpeg_required_vars}_LIBRARIES") "FFMPEG_${_ffmpeg_component}_LIBRARIES")
endif()
endif () endif ()
endif () endif ()
endforeach () endforeach ()
@ -187,7 +212,7 @@ endif ()
include(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(FFMPEG find_package_handle_standard_args(FFMPEG
REQUIRED_VARS FFMPEG_INCLUDE_DIRS FFMPEG_LIBRARIES ${_ffmpeg_required_vars} REQUIRED_VARS ${_ffmpeg_required_vars}
VERSION_VAR FFMPEG_VERSION VERSION_VAR FFMPEG_VERSION
HANDLE_COMPONENTS) HANDLE_COMPONENTS)
unset(_ffmpeg_required_vars) unset(_ffmpeg_required_vars)

12
scripts/build-ffmpeg.sh Executable file
View file

@ -0,0 +1,12 @@
#!/bin/bash
cd $(dirname "${BASH_SOURCE[0]}")/..
ROOT="`pwd`"
TAG=n4.2
git clone https://git.ffmpeg.org/ffmpeg.git --depth 1 -b $TAG && cd ffmpeg || exit 1
./configure --disable-all --enable-avcodec --enable-decoder=h264 --prefix="$ROOT/ffmpeg-prefix" || exit 1
make -j4 || exit 1
make install || exit 1