1# 2# Find the native FFMPEG includes and library 3# This module defines 4# FFMPEG_INCLUDE_DIR, where to find avcodec.h, avformat.h ... 5# FFMPEG_LIBRARIES, the libraries to link against to use FFMPEG. 6# FFMPEG_FOUND, If false, do not try to use FFMPEG. 7# FFMPEG_ROOT, if this module use this path to find FFMPEG headers 8# and libraries. 9 10# Macro to find header and lib directories 11# example: FFMPEG_FIND(AVFORMAT avformat avformat.h) 12MACRO(FFMPEG_FIND varname shortname headername) 13 # old version of ffmpeg put header in $prefix/include/[ffmpeg] 14 # so try to find header in include directory 15 FIND_PATH(FFMPEG_${varname}_INCLUDE_DIRS lib${shortname}/${headername} 16 PATHS 17 ${FFMPEG_ROOT}/include/lib${shortname} 18 $ENV{FFMPEG_DIR}/include/lib${shortname} 19 ~/Library/Frameworks/lib${shortname} 20 /Library/Frameworks/lib${shortname} 21 /usr/local/include/lib${shortname} 22 /usr/include/lib${shortname} 23 /sw/include/lib${shortname} # Fink 24 /opt/local/include/lib${shortname} # DarwinPorts 25 /opt/csw/include/lib${shortname} # Blastwave 26 /opt/include/lib${shortname} 27 /usr/freeware/include/lib${shortname} 28 PATH_SUFFIXES ffmpeg 29 DOC "Location of FFMPEG Headers" 30 ) 31 32 FIND_PATH(FFMPEG_${varname}_INCLUDE_DIRS lib${shortname}/${headername} 33 PATHS 34 ${FFMPEG_ROOT}/include 35 $ENV{FFMPEG_DIR}/include 36 ~/Library/Frameworks 37 /Library/Frameworks 38 /usr/local/include 39 /usr/include 40 /sw/include # Fink 41 /opt/local/include # DarwinPorts 42 /opt/csw/include # Blastwave 43 /opt/include 44 /usr/freeware/include 45 PATH_SUFFIXES ffmpeg 46 DOC "Location of FFMPEG Headers" 47 ) 48 49 FIND_LIBRARY(FFMPEG_${varname}_LIBRARIES 50 NAMES ${shortname} 51 PATHS 52 ${FFMPEG_ROOT}/lib 53 $ENV{FFMPEG_DIR}/lib 54 ~/Library/Frameworks 55 /Library/Frameworks 56 /usr/local/lib 57 /usr/local/lib64 58 /usr/lib/x86_64-linux-gnu 59 /usr/lib 60 /usr/lib64 61 /sw/lib 62 /opt/local/lib 63 /opt/csw/lib 64 /opt/lib 65 /usr/freeware/lib64 66 DOC "Location of FFMPEG Libraries" 67 ) 68 69 IF (FFMPEG_${varname}_LIBRARIES AND FFMPEG_${varname}_INCLUDE_DIRS) 70 SET(FFMPEG_${varname}_FOUND 1) 71 ENDIF(FFMPEG_${varname}_LIBRARIES AND FFMPEG_${varname}_INCLUDE_DIRS) 72 73ENDMACRO(FFMPEG_FIND) 74 75SET(FFMPEG_ROOT "$ENV{FFMPEG_DIR}" CACHE PATH "Location of FFMPEG") 76 77# find stdint.h 78IF(WIN32) 79 80 FIND_PATH(FFMPEG_STDINT_INCLUDE_DIR stdint.h 81 PATHS 82 ${FFMPEG_ROOT}/include 83 $ENV{FFMPEG_DIR}/include 84 ~/Library/Frameworks 85 /Library/Frameworks 86 /usr/local/include 87 /usr/include 88 /sw/include # Fink 89 /opt/local/include # DarwinPorts 90 /opt/csw/include # Blastwave 91 /opt/include 92 /usr/freeware/include 93 PATH_SUFFIXES ffmpeg 94 DOC "Location of FFMPEG stdint.h Header" 95 ) 96 97 IF (FFMPEG_STDINT_INCLUDE_DIR) 98 SET(STDINT_OK TRUE) 99 ENDIF() 100 101ELSE() 102 103 SET(STDINT_OK TRUE) 104 105ENDIF() 106 107FFMPEG_FIND(LIBAVFORMAT avformat avformat.h) 108#FFMPEG_FIND(LIBAVDEVICE avdevice avdevice.h) 109FFMPEG_FIND(LIBAVCODEC avcodec avcodec.h) 110FFMPEG_FIND(LIBAVUTIL avutil avutil.h) 111#FFMPEG_FIND(LIBSWSCALE swscale swscale.h) # not sure about the header to look for here. 112#FFMPEG_FIND(LIBX264 x264 x264.h) 113#FFMPEG_FIND(LIBX265 x265 x265.h) 114 115SET(FFMPEG_FOUND "NO") 116 117# Note we don't check FFMPEG_LIBSWSCALE_FOUND, FFMPEG_LIBAVDEVICE_FOUND, 118# and FFMPEG_LIBAVUTIL_FOUND as they are optional. 119IF (FFMPEG_LIBAVFORMAT_FOUND AND FFMPEG_LIBAVCODEC_FOUND AND STDINT_OK) 120 121 SET(FFMPEG_FOUND "YES") 122 123 SET(FFMPEG_INCLUDE_DIR ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}) 124 125 SET(FFMPEG_LIBRARY_DIRS ${FFMPEG_LIBAVFORMAT_LIBRARY_DIRS}) 126 127 # Note we don't add FFMPEG_LIBSWSCALE_LIBRARIES here, 128 # it will be added if found later. 129 SET(FFMPEG_LIBRARIES 130 ${FFMPEG_LIBAVFORMAT_LIBRARIES} 131 ${FFMPEG_LIBAVDEVICE_LIBRARIES} 132 ${FFMPEG_LIBAVCODEC_LIBRARIES} 133 ${FFMPEG_LIBAVUTIL_LIBRARIES} 134 ${FFMPEG_LIBSWSCALE_LIBRARIES} 135 ${FFMPEG_LIBX264_LIBRARIES} 136 ${FFMPEG_LIBX265_LIBRARIES}) 137ENDIF() 138