@@ -59,6 +59,10 @@ option(WHISPER_BUILD_EXAMPLES "whisper: build examples" ${WHISPER_STANDA
59
59
60
60
option (WHISPER_SDL2 "whisper: support for libSDL2" OFF )
61
61
62
+ if (CMAKE_SYSTEM_NAME MATCHES "Linux" )
63
+ option (WHISPER_FFMPEG "whisper: support building and linking with ffmpeg libs" OFF )
64
+ endif ()
65
+
62
66
option (WHISPER_NO_AVX "whisper: disable AVX" OFF )
63
67
option (WHISPER_NO_AVX2 "whisper: disable AVX2" OFF )
64
68
option (WHISPER_NO_AVX512 "whisper: disable AVX512" ON )
@@ -125,6 +129,23 @@ else()
125
129
set (CMAKE_CXX_STANDARD 11)
126
130
endif ()
127
131
132
+ if (WHISPER_FFMPEG)
133
+ # As today (cmake 3.27), there is no official cmake support for FindFFmpeg. eg: not possible:
134
+ # find_package(FFmpeg COMPONENTS AVCODEC AVFORMAT AVUTIL AVDEVICE REQUIRED)
135
+ # Check with reviewers: worth to embed a FindFFmpeg.cmake script in whisper.cpp ?
136
+ # eg https://github.com/snikulov/cmake-modules/blob/master/FindFFmpeg.cmake
137
+ # Using PkgConfig atm:
138
+ find_package (PkgConfig REQUIRED)
139
+ pkg_check_modules(FFMPEG REQUIRED IMPORTED_TARGET libavdevice libavfilter libavformat libavcodec libswresample libswscale libavutil)
140
+ if (NOT ${FFMPEG_FOUND} )
141
+ message (FATAL_ERROR "Cannot find ffmpeg libs/headers" )
142
+ endif ()
143
+ message (STATUS "Found ffmpeg headers in: ${FFMPEG_INCLUDE_DIRS} " )
144
+ include_directories (${FFMPEG_INCLUDE_DIRS} )
145
+ add_compile_definitions (WHISPER_FFMPEG)
146
+ set (WHISPER_EXTRA_LIBS ${WHISPER_EXTRA_LIBS} PkgConfig::FFMPEG)
147
+ endif ()
148
+
128
149
# on APPLE
129
150
if (APPLE )
130
151
# include Accelerate framework
0 commit comments