diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 65fe8225ab4..385ac359c23 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -33,6 +33,9 @@ jobs: ccache-${{ github.job }}-${{ github.ref }}- ccache-${{ github.job }}- path: ~/.ccache + - name: Install FFmpeg + run: | + apt-get --yes install libavcodec-dev libavformat-dev libavutil-dev libavdevice-dev libswresample-dev - name: Configure run: | ccache --zero-stats @@ -207,6 +210,29 @@ jobs: ccache-${{ github.job }}-${{ matrix.arch }}-${{ github.ref }}- ccache-${{ github.job }}-${{ matrix.arch }}- path: ~/.ccache + - name: Cross Compile FFmpeg + run: | + apt-get --yes install yasm + git clone -c http.sslVerify=false https://git.ffmpeg.org/ffmpeg.git ffmpeg + + if [ ${{ matrix.arch }} == 32 ]; then + FFMPEG_CROSS_PREFIX=i686-w64-mingw32 + elif [ ${{ matrix.arch }} == 64 ]; then + FFMPEG_CROSS_PREFIX=x86_64-w64-mingw32 + fi + + cd ffmpeg + ./configure \ + --arch=x86 \ + --target-os=mingw32 \ + --enable-cross-compile \ + --prefix=/usr/$FFMPEG_CROSS_PREFIX \ + --cross-prefix=$FFMPEG_CROSS_PREFIX- \ + --x86asmexe=yasm \ + --disable-programs \ + --disable-doc + make && make install + shell: bash - name: Configure run: | ccache --zero-stats diff --git a/Brewfile b/Brewfile index 42ae8180d53..dd8ad1e8578 100644 --- a/Brewfile +++ b/Brewfile @@ -17,3 +17,4 @@ brew "portaudio" brew "qt@5" brew "sdl2" brew "stk" +brew "ffmpeg" \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 5bb4adc4aa8..f3a7da134a9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -221,6 +221,10 @@ IF(SNDFILE_FOUND) ELSE() MESSAGE(FATAL_ERROR "LMMS requires libsndfile1 and libsndfile1-dev >= 1.0.18 - please install, remove CMakeCache.txt and try again!") ENDIF() + +# check for FFmpeg +FIND_PACKAGE(FFMPEG REQUIRED COMPONENTS avcodec avformat avutil avdevice swresample) + # check if we can use SFC_SET_COMPRESSION_LEVEL INCLUDE(CheckCXXSourceCompiles) CHECK_CXX_SOURCE_COMPILES( diff --git a/cmake/modules/FindFFMPEG.cmake b/cmake/modules/FindFFMPEG.cmake new file mode 100644 index 00000000000..348dafe28d7 --- /dev/null +++ b/cmake/modules/FindFFMPEG.cmake @@ -0,0 +1,89 @@ +# Distributed under the MIT License. +# Copyright (c) 2022 sakertooth + +#[=======================================================================[.rst: +FindFFMPEG +------- + +Finds the FFmpeg library. + +Result Variables +^^^^^^^^^^^^^^^^ + +This will define the following variables: + +``FFMPEG_FOUND`` + True if the system has found the required FFmpeg components. + +``FFMPEG_INCLUDE_DIRS`` + The include directories of the required FFmpeg components. + +``FFMPEG_LIBRARIES`` + The libraries of the required FFmpeg components. + + +Cache Variables +^^^^^^^^^^^^^^^ + +For each FFmpeg component: + avcodec, + avformat, + avutil, + avfilter, + avdevice, + swresample, + swscale + +The following cache variables may also be set: + +``FFMPEG__INCLUDE_DIR`` + The include directory for the FFmpeg component. + +``FFMPEG__LIBRARY`` + The library for the FFmpeg component. + +#]=======================================================================] + +find_package(PkgConfig QUIET) +set(_possibleComponents avcodec avformat avutil avfilter avdevice swresample swscale) + +foreach(component ${FFMPEG_FIND_COMPONENTS}) + string(TOUPPER ${component} _upperComponent) + if(PKG_CONFIG_FOUND) + pkg_check_modules(PC_${_upperComponent} lib${component}) + endif() + + if(NOT ${component} IN_LIST _possibleComponents) + message(FATAL_ERROR "Unknown FFmpeg component: ${component}") + endif() + + find_path(FFMPEG_${_upperComponent}_INCLUDE_DIR + NAMES lib${component}/${component}.h + HINTS ${PC_${_upperComponent}_INCLUDE_DIRS} + ) + + find_library(FFMPEG_${_upperComponent}_LIBRARY + NAMES ${component} + HINTS ${PC_${_upperComponent}_LIBRARY_DIR} + ) + + if (FFMPEG_${_upperComponent}_INCLUDE_DIR AND FFMPEG_${_upperComponent}_LIBRARY) + set(FFMPEG_${_upperComponent}_FOUND TRUE) + set(FFMPEG_${_upperComponent}_VERSION ${PC_${_upperComponent}_VERSION}) + set(FFMPEG_INCLUDE_DIRS ${FFMPEG_INCLUDE_DIRS} ${FFMPEG_${_upperComponent}_INCLUDE_DIR}) + set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} ${FFMPEG_${_upperComponent}_LIBRARY}) + + mark_as_advanced( + FFMPEG_${_upperComponent}_INCLUDE_DIR + FFMPEG_${_upperComponent}_LIBRARY + ) + endif() + + set(FFMPEG_REQUIRED_VARS ${FFMPEG_REQUIRED_VARS} + FFMPEG_${_upperComponent}_INCLUDE_DIR + FFMPEG_${_upperComponent}_LIBRARY + ) +endforeach() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(FFMPEG DEFAULT_MSG ${FFMPEG_REQUIRED_VARS}) \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c458a5cd227..a8bd2f66e19 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -58,6 +58,7 @@ include_directories(SYSTEM ${JACK_INCLUDE_DIRS} ${SNDIO_INCLUDE_DIRS} ${FFTW3F_INCLUDE_DIRS} + ${FFMPEG_INCLUDE_DIRS} ) IF(NOT ("${PULSEAUDIO_INCLUDE_DIR}" STREQUAL "")) @@ -164,6 +165,7 @@ SET(LMMS_REQUIRED_LIBS ${LMMS_REQUIRED_LIBS} ${SUIL_LIBRARIES} ${LILV_LIBRARIES} ${FFTW3F_LIBRARIES} + ${FFMPEG_LIBRARIES} SampleRate::samplerate SndFile::sndfile ${EXTRA_LIBRARIES}