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 2 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
30 changes: 28 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,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: |
source /opt/qt5*/bin/qt5*-env.sh || true
Expand Down Expand Up @@ -92,7 +95,7 @@ jobs:
run: |
brew install ccache fftw pkg-config libogg libvorbis lame libsndfile \
libsamplerate jack sdl libgig libsoundio lilv lv2 stk \
fluid-synth portaudio fltk qt@5 carla
fluid-synth portaudio fltk qt@5 carla ffmpeg
npm install --location=global appdmg
- name: Configure
run: |
Expand Down Expand Up @@ -160,6 +163,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: |
mkdir build && cd build
Expand Down Expand Up @@ -223,7 +249,7 @@ jobs:
- name: Install dependencies
run: |
vcpkg install --triplet ${{ matrix.arch }}-windows --recurse `
fftw3 libsamplerate libsndfile lilv lv2 sdl2
fftw3 libsamplerate libsndfile lilv lv2 sdl2 ffmpeg[core,avcodec,avformat,avdevice,swresample]
- name: Set up build environment
uses: ilammy/msvc-dev-cmd@d8610e2b41c6d0f0c3b4c46dad8df0fd826c68e1
with:
Expand Down
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@ FIND_PACKAGE(SndFile REQUIRED)
IF(NOT SNDFILE_FOUND)
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
88 changes: 88 additions & 0 deletions cmake/modules/FindFFMPEG.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# 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)
set(_possibleComponents avcodec avformat avutil avfilter avdevice swresample swscale)

foreach(component ${FFMPEG_FIND_COMPONENTS})
string(TOUPPER ${component} _upperComponent)
pkg_check_modules(PC_${_upperComponent} lib${component})

LIST(FIND _possibleComponents ${component} _componentIndex)
if(${_componentIndex} EQUAL -1)
message(FATAL_ERROR "Unknown FFmpeg component: ${component}")
endif()

find_path(FFMPEG_${_upperComponent}_INCLUDE_DIR
NAMES lib${component}/${component}.h
PATHS ${PC_${_upperComponent}_INCLUDE_DIRS}
)

find_library(FFMPEG_${_upperComponent}_LIBRARY
NAMES ${component}
PATHS ${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 @@ -62,6 +62,7 @@ INCLUDE_DIRECTORIES(
${SNDFILE_INCLUDE_DIRS}
${SNDIO_INCLUDE_DIRS}
${FFTW3F_INCLUDE_DIRS}
${FFMPEG_INCLUDE_DIRS}
)

IF(NOT LMMS_HAVE_SDL2 AND NOT ("${SDL_INCLUDE_DIR}" STREQUAL ""))
Expand Down Expand Up @@ -189,6 +190,7 @@ SET(LMMS_REQUIRED_LIBS ${LMMS_REQUIRED_LIBS}
${SAMPLERATE_LIBRARIES}
${SNDFILE_LIBRARIES}
${FFTW3F_LIBRARIES}
${FFMPEG_LIBRARIES}
${EXTRA_LIBRARIES}
rpmalloc
)
Expand Down