Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add FFmpeg #6430

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions Brewfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ brew "portaudio"
brew "qt@5"
brew "sdl2"
brew "stk"
brew "ffmpeg"
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
89 changes: 89 additions & 0 deletions cmake/modules/FindFFMPEG.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Distributed under the MIT License.
# Copyright (c) 2022 sakertooth <[email protected]>

#[=======================================================================[.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_<component>_INCLUDE_DIR``
The include directory for the FFmpeg component.

``FFMPEG_<component>_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})
2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""))
Expand Down Expand Up @@ -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}
Expand Down
Loading