Skip to content

Commit

Permalink
[ffmpeg] Some libraries in ffmpeg can be optional (#12843)
Browse files Browse the repository at this point in the history
* Make sub libraries of FFmpeg optional

avdevice
avfilter
swresample
swscale

* Also adding avcodec and avformat

* This should have been avcodec obviously
  • Loading branch information
sandercox committed Aug 14, 2020
1 parent 0c753a2 commit 234f7e4
Show file tree
Hide file tree
Showing 3 changed files with 119 additions and 17 deletions.
22 changes: 20 additions & 2 deletions ports/ffmpeg/CONTROL
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Source: ffmpeg
Version: 4.2
Port-Version: 17
Port-Version: 18
Build-Depends: zlib
Homepage: https://ffmpeg.org
Description: a library to decode, encode, transcode, mux, demux, stream, filter and play pretty much anything that humans and machines have created.
FFmpeg is the leading multimedia framework, able to decode, encode, transcode, mux, demux, stream, filter and play pretty much anything that humans and machines have created. It supports the most obscure ancient formats up to the cutting edge. No matter if they were designed by some standards committee, the community or a corporation. It is also highly portable: FFmpeg compiles, runs, and passes our testing infrastructure FATE across Linux, Mac OS X, Microsoft Windows, the BSDs, Solaris, etc. under a wide variety of build environments, machine architectures, and configurations.
Default-Features: avresample
Default-Features: avresample, avcodec, avformat, avdevice, avfilter, swresample, swscale

Feature: ffmpeg
Description: build the ffmpeg.exe application
Expand Down Expand Up @@ -55,6 +55,24 @@ Description: upgrade (L)GPL to version 3
Feature: avresample
Description: Libav audio resampling library support in ffmpeg

Feature: avcodec
Description: Codec support in ffmpeg

Feature: avformat
Description: Format support in ffmpeg

Feature: avdevice
Description: Device support in ffmpeg

Feature: avfilter
Description: Filter support in ffmpeg

Feature: swresample
Description: Swresample support in ffmpeg

Feature: swscale
Description: Swscale support in ffmpeg

Feature: nvcodec
Build-Depends: ffnvcodec, cuda
Description: Hardware accelerated codecs
Expand Down
66 changes: 51 additions & 15 deletions ports/ffmpeg/FindFFMPEG.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -131,32 +131,68 @@ if(APPLE)
list(APPEND FFMPEG_PLATFORM_DEPENDENT_LIBS ${VT_UNIT} ${AT_UNIT} ${SEC_UNIT} ${CF_UNIT} ${CM_UNIT} ${CV_UNIT} ${Iconv_LIBRARIES})
endif()

FFMPEG_FIND(libavcodec avcodec avcodec.h)
FFMPEG_FIND(libavdevice avdevice avdevice.h)
FFMPEG_FIND(libavfilter avfilter avfilter.h)
FFMPEG_FIND(libavformat avformat avformat.h)
if(@ENABLE_AVCODEC@)
FFMPEG_FIND(libavcodec avcodec avcodec.h)
endif()
if(@ENABLE_AVDEVICE@)
FFMPEG_FIND(libavdevice avdevice avdevice.h)
endif()
if(@ENABLE_AVFILTER@)
FFMPEG_FIND(libavfilter avfilter avfilter.h)
endif()
if(@ENABLE_AVFORMAT@)
FFMPEG_FIND(libavformat avformat avformat.h)
endif()
if(@ENABLE_AVRESAMPLE@)
FFMPEG_FIND(libavresample avresample avresample.h)
endif()
FFMPEG_FIND(libavutil avutil avutil.h)
FFMPEG_FIND(libswresample swresample swresample.h)
FFMPEG_FIND(libswscale swscale swscale.h)

if (FFMPEG_libavcodec_FOUND AND FFMPEG_libavdevice_FOUND AND FFMPEG_libavfilter_FOUND AND FFMPEG_libavformat_FOUND AND FFMPEG_libavutil_FOUND AND FFMPEG_libswresample_FOUND AND FFMPEG_libswscale_FOUND AND FFMPEG_libzlib_FOUND)
list(APPEND FFMPEG_INCLUDE_DIRS ${FFMPEG_libavformat_INCLUDE_DIRS} ${FFMPEG_libavdevice_INCLUDE_DIRS} ${FFMPEG_libavcodec_INCLUDE_DIRS} ${FFMPEG_libavutil_INCLUDE_DIRS} ${FFMPEG_libswscale_INCLUDE_DIRS})
if(@ENABLE_SWRESAMPLE@)
FFMPEG_FIND(libswresample swresample swresample.h)
endif()
if(@ENABLE_SWSCALE@)
FFMPEG_FIND(libswscale swscale swscale.h)
endif(@ENABLE_SWSCALE@)

if (FFMPEG_libavutil_FOUND AND FFMPEG_libzlib_FOUND)
list(APPEND FFMPEG_INCLUDE_DIRS ${FFMPEG_libavutil_INCLUDE_DIRS})
if(FFMPEG_libavcodec_FOUND)
list(APPEND FFMPEG_INCLUDE_DIRS ${FFMPEG_libavcodec_INCLUDE_DIRS})
endif()
if(FFMPEG_libavdevice_FOUND)
list(APPEND FFMPEG_INCLUDE_DIRS ${FFMPEG_libavdevice_INCLUDE_DIRS})
endif()
if(FFMPEG_libavformat_FOUND)
list(APPEND FFMPEG_INCLUDE_DIRS ${FFMPEG_libavformat_INCLUDE_DIRS})
endif()
if(FFMPEG_libswscale_FOUND)
list(APPEND FFMPEG_INCLUDE_DIRS ${FFMPEG_libswscale_INCLUDE_DIRS})
endif()
list(REMOVE_DUPLICATES FFMPEG_INCLUDE_DIRS)
list(REMOVE_DUPLICATES FFMPEG_LIBRARY_DIRS)

set(FFMPEG_libavcodec_VERSION "${FFMPEG_VERSION}" CACHE STRING "")
set(FFMPEG_libavdevice_VERSION "${FFMPEG_VERSION}" CACHE STRING "")
set(FFMPEG_libavfilter_VERSION "${FFMPEG_VERSION}" CACHE STRING "")
set(FFMPEG_libavformat_VERSION "${FFMPEG_VERSION}" CACHE STRING "")
if(FFMPEG_libavcodec_FOUND)
set(FFMPEG_libavcodec_VERSION "${FFMPEG_VERSION}" CACHE STRING "")
endif()
if(FFMPEG_libavdevice_FOUND)
set(FFMPEG_libavdevice_VERSION "${FFMPEG_VERSION}" CACHE STRING "")
endif()
if(FFMPEG_libavfilter_FOUND)
set(FFMPEG_libavfilter_VERSION "${FFMPEG_VERSION}" CACHE STRING "")
endif()
if(FFMPEG_libavformat_FOUND)
set(FFMPEG_libavformat_VERSION "${FFMPEG_VERSION}" CACHE STRING "")
endif()
if(FFMPEG_libavresample_FOUND)
set(FFMPEG_libavresample_VERSION "${FFMPEG_VERSION}" CACHE STRING "")
endif()
set(FFMPEG_libavutil_VERSION "${FFMPEG_VERSION}" CACHE STRING "")
set(FFMPEG_libswresample_VERSION "${FFMPEG_VERSION}" CACHE STRING "")
set(FFMPEG_libswscale_VERSION "${FFMPEG_VERSION}" CACHE STRING "")
if(FFMPEG_libswresample_FOUND)
set(FFMPEG_libswresample_VERSION "${FFMPEG_VERSION}" CACHE STRING "")
endif()
if(FFMPEG_libswscale_FOUND)
set(FFMPEG_libswscale_VERSION "${FFMPEG_VERSION}" CACHE STRING "")
endif()

list(APPEND FFMPEG_LIBRARIES
${FFMPEG_libavdevice_LIBRARY}
Expand Down
48 changes: 48 additions & 0 deletions ports/ffmpeg/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,54 @@ if("avresample" IN_LIST FEATURES)
set(ENABLE_AVRESAMPLE ON) #necessary for configuring FFMPEG CMake Module
endif()

if("avcodec" IN_LIST FEATURES)
set(OPTIONS "${OPTIONS} --enable-avcodec")
set(ENABLE_AVCODEC ON)
else()
set(OPTIONS "${OPTIONS} --disable-avcodec")
set(ENABLE_AVCODEC OFF)
endif()

if("avdevice" IN_LIST FEATURES)
set(OPTIONS "${OPTIONS} --enable-avdevice")
set(ENABLE_AVDEVICE ON)
else()
set(OPTIONS "${OPTIONS} --disable-avdevice")
set(ENABLE_AVDEVICE OFF)
endif()

if("avformat" IN_LIST FEATURES)
set(OPTIONS "${OPTIONS} --enable-avformat")
set(ENABLE_AVFORMAT ON)
else()
set(OPTIONS "${OPTIONS} --disable-avformat")
set(ENABLE_AVFORMAT OFF)
endif()

if("avfilter" IN_LIST FEATURES)
set(OPTIONS "${OPTIONS} --enable-avfilter")
set(ENABLE_AVFILTER ON)
else()
set(OPTIONS "${OPTIONS} --disable-avfilter")
set(ENABLE_AVFILTER OFF)
endif()

if("swresample" IN_LIST FEATURES)
set(OPTIONS "${OPTIONS} --enable-swresample")
set(ENABLE_SWRESAMPLE ON)
else()
set(OPTIONS "${OPTIONS} --disable-swresample")
set(ENABLE_SWRESAMPLE OFF)
endif()

if("swscale" IN_LIST FEATURES)
set(OPTIONS "${OPTIONS} --enable-swscale")
set(ENABLE_SWSCALE ON)
else()
set(OPTIONS "${OPTIONS} --disable-swscale")
set(ENABLE_SWSCALE OFF)
endif()

if (VCPKG_TARGET_IS_OSX)
set(OPTIONS "${OPTIONS} --disable-vdpau") # disable vdpau in OSX
endif()
Expand Down

0 comments on commit 234f7e4

Please sign in to comment.