Warning, /graphics/digikam/core/cmake/rules/RulesFFmpeg.cmake is written in an unsupported language. File is not indexed.

0001 #
0002 # SPDX-FileCopyrightText: 2010-2024 by Gilles Caulier, <caulier dot gilles at gmail dot com>
0003 #
0004 # SPDX-License-Identifier: BSD-3-Clause
0005 #
0006 
0007 find_package(FFmpeg REQUIRED COMPONENTS AVCODEC
0008                                         AVDEVICE
0009                                         AVFILTER
0010                                         AVFORMAT
0011                                         AVUTIL
0012                                         SWSCALE
0013                                         SWRESAMPLE
0014 )
0015 
0016 find_package(FFmpeg OPTIONAL_COMPONENTS AVRESAMPLE)     # removed with ffmpeg 5
0017 
0018 message(STATUS "FFMpeg AVCodec    (required) : ${AVCODEC_FOUND} (${AVCODEC_VERSION})")
0019 message(STATUS "FFMpeg AVDevice   (required) : ${AVDEVICE_FOUND} (${AVDEVICE_VERSION})")
0020 message(STATUS "FFMpeg AVFilter   (required) : ${AVFILTER_FOUND} (${AVFILTER_VERSION})")
0021 message(STATUS "FFMpeg AVFormat   (required) : ${AVFORMAT_FOUND} (${AVFORMAT_VERSION})")
0022 message(STATUS "FFMpeg AVUtil     (required) : ${AVUTIL_FOUND} (${AVUTIL_VERSION})")
0023 message(STATUS "FFMpeg SWScale    (required) : ${SWSCALE_FOUND} (${SWSCALE_VERSION})")
0024 message(STATUS "FFMpeg SWResample (required) : ${SWRESAMPLE_FOUND} (${SWRESAMPLE_VERSION})")
0025 message(STATUS "FFMpeg AVResample (optional) : ${AVRESAMPLE_FOUND} (${AVRESAMPLE_VERSION})")
0026 
0027 if(${AVCODEC_FOUND}     AND
0028    ${AVDEVICE_FOUND}    AND
0029    ${AVFILTER_FOUND}    AND
0030    ${AVFORMAT_FOUND}    AND
0031    ${AVUTIL_FOUND}      AND
0032    ${SWSCALE_FOUND}     AND
0033    ${SWRESAMPLE_FOUND}
0034   )
0035 
0036     include_directories(${FFMPEG_INCLUDE_DIRS})
0037     set(FFMPEG_FOUND ON)
0038     message(STATUS "FFmpeg support is enabled : yes")
0039 
0040 else()
0041 
0042     set(ENABLE_MEDIAPLAYER OFF)
0043     set(FFMPEG_FOUND OFF)
0044     message(STATUS "FFmpeg support is enabled : no")
0045 
0046 endif()
0047 
0048 if (${FFMPEG_FOUND})
0049 
0050     # Check if FFMPEG 5 API is available
0051 
0052     if (AVCODEC_VERSION)
0053 
0054         string(REPLACE "." ";" VERSION_LIST ${AVCODEC_VERSION})
0055         list(GET VERSION_LIST 0 AVCODEC_VERSION_MAJOR)
0056         list(GET VERSION_LIST 1 AVCODEC_VERSION_MINOR)
0057         list(GET VERSION_LIST 2 AVCODEC_VERSION_PATCH)
0058 
0059         if (${AVCODEC_VERSION_MAJOR} GREATER_EQUAL 59)
0060 
0061             set(FFMPEG_VER5_FOUND 1)
0062 
0063         endif()
0064 
0065     endif()
0066 
0067     if (FFMPEG_VER5_FOUND)
0068 
0069         message(STATUS "FFMpeg >= 5 API           : yes")
0070 
0071         # This definition is used in video thumbnails code.
0072 
0073         add_definitions(-DHAVE_FFMPEG_VERSION5)
0074 
0075     else()
0076 
0077         message(STATUS "FFMpeg >= 5 API           : no")
0078 
0079     endif()
0080 
0081     MACRO_BOOL_TO_01(AVCODEC_FOUND         HAVE_LIBAVCODEC)
0082     MACRO_BOOL_TO_01(AVDEVICE_FOUND        HAVE_LIBAVDEVICE)
0083     MACRO_BOOL_TO_01(AVFILTER_FOUND        HAVE_LIBAVFILTER)
0084     MACRO_BOOL_TO_01(AVFORMAT_FOUND        HAVE_LIBAVFORMAT)
0085     MACRO_BOOL_TO_01(AVUTIL_FOUND          HAVE_LIBAVUTIL)
0086     MACRO_BOOL_TO_01(SWSCALE_FOUND         HAVE_LIBSWSCALE)
0087     MACRO_BOOL_TO_01(SWRESAMPLE_FOUND      HAVE_LIBSWRESAMPLE)
0088     MACRO_BOOL_TO_01(AVRESAMPLE_FOUND      HAVE_LIBAVRESAMPLE)
0089 
0090     if(NOT AVRESAMPLE_FOUND)
0091 
0092         set(AVRESAMPLE_LIBRARIES "")
0093 
0094     endif()
0095 
0096     set(MEDIAPLAYER_LIBRARIES ${AVCODEC_LIBRARIES}
0097                               ${AVDEVICE_LIBRARIES}
0098                               ${AVFILTER_LIBRARIES}
0099                               ${AVFORMAT_LIBRARIES}
0100                               ${AVUTIL_LIBRARIES}
0101                               ${SWSCALE_LIBRARIES}
0102                               ${SWRESAMPLE_LIBRARIES}
0103                               ${AVRESAMPLE_LIBRARIES}   # optional with FFMPEG 4 and removed with FFMPEG 5
0104                               ${CMAKE_DL_LIBS}
0105     )
0106 
0107 endif()