Skip to content

Commit

Permalink
Implement VideoPlayer using FFMPEG KD-lab-Open-Source#48
Browse files Browse the repository at this point in the history
  • Loading branch information
IonAgorria committed Dec 29, 2021
1 parent 930378f commit a82516e
Show file tree
Hide file tree
Showing 39 changed files with 1,730 additions and 820 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/linux_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: update repos
run: sudo apt-get update
- name: install libs
run: sudo apt-get install cmake meson libsdl2-dev libsdl2-image-dev libsdl2-net-dev libsdl2-mixer-dev libboost-dev libavcodec-dev libavformat-dev zlib1g-dev libvulkan-dev glslang-tools lld
run: sudo apt-get install cmake meson libsdl2-dev libsdl2-image-dev libsdl2-net-dev libsdl2-mixer-dev libboost-dev libavcodec-dev libavformat-dev libavfilter-dev libswscale-dev zlib1g-dev libvulkan-dev glslang-tools lld
- name: create build dir
run: mkdir build
- name: configure
Expand Down Expand Up @@ -55,7 +55,7 @@ jobs:
- name: update repos
run: sudo apt-get update
- name: install libs
run: sudo apt-get install cmake meson libsdl2-dev libsdl2-image-dev libsdl2-net-dev libsdl2-mixer-dev libboost-dev libavcodec-dev libavformat-dev zlib1g-dev libvulkan-dev glslang-tools lld
run: sudo apt-get install cmake meson libsdl2-dev libsdl2-image-dev libsdl2-net-dev libsdl2-mixer-dev libboost-dev libavcodec-dev libavformat-dev libavfilter-dev libswscale-dev zlib1g-dev libvulkan-dev glslang-tools lld
- name: create build dir
run: mkdir build
- name: configure
Expand Down
18 changes: 11 additions & 7 deletions .github/workflows/macos_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
env:
VULKAN_SDK_VERSION: '1.2.189.0'
MACOSX_DEPLOYMENT_TARGET: '10.15'
GH_CACHE_KEY: 4
GH_CACHE_KEY: 8

jobs:
build:
Expand All @@ -27,7 +27,7 @@ jobs:
- name: install libs
run: |
brew install ninja yasm dylibbundler \
libogg libvorbis boost meson cmake zlib \
libogg libvorbis libvpx boost meson cmake zlib \
sdl2 sdl2_image sdl2_mixer sdl2_net
- uses: actions/cache@v2
id: cache
Expand All @@ -47,10 +47,10 @@ jobs:
hdiutil detach /Volumes/vulkansdk-macos-${{ env.VULKAN_SDK_VERSION }}
- name: ffmpeg -- download
if: steps.cache.outputs.cache-hit != 'true'
run: git clone --depth 1 --branch n4.3.3 https://git.ffmpeg.org/ffmpeg.git ffmpeg
run: git clone --depth 1 --branch n4.4.1 https://git.ffmpeg.org/ffmpeg.git ffmpeg
- name: ffmpeg -- configure
if: steps.cache.outputs.cache-hit != 'true'
run: ./configure --enable-shared --prefix=/usr/local
run: ./configure --enable-shared --prefix=/usr/local
--cc="clang"
--arch=${{matrix.env.arch}}
--extra-cflags="-arch ${{matrix.env.arch_apple}}"
Expand All @@ -59,10 +59,14 @@ jobs:
--sysroot=$(xcrun --sdk macosx --show-sdk-path)
--disable-everything
--enable-swscale
--enable-swresample
--enable-zlib
--enable-demuxer=avi,rawvideo
--enable-decoder=png,bink,rawvideo
--enable-parser=png
--enable-libvpx
--enable-libvorbis
--enable-demuxer=avi,rawvideo,bink,matroska
--enable-decoder=png,rawvideo,bink,binkaudio_dct,vorbis,opus,vp8,vp9
--enable-parser=png,vp9
--enable-filter=aresample,aformat
--enable-protocol=file
--disable-d3d11va
--disable-dxva2
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/windows_msvc_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ jobs:
copy ${{ env.buildDir }}vcpkg_installed/${{matrix.env.arch_installed}}-windows/bin/ogg.dll ${{ env.outDir }}
copy ${{ env.buildDir }}vcpkg_installed/${{matrix.env.arch_installed}}-windows/bin/vorbis.dll ${{ env.outDir }}
copy ${{ env.buildDir }}vcpkg_installed/${{matrix.env.arch_installed}}-windows/bin/vorbisfile.dll ${{ env.outDir }}
copy ${{ env.buildDir }}vcpkg_installed/${{matrix.env.arch_installed}}-windows/bin/swscale-5.dll ${{ env.outDir }}
copy ${{ env.buildDir }}vcpkg_installed/${{matrix.env.arch_installed}}-windows/bin/swresample-3.dll ${{ env.outDir }}
copy ${{ env.buildDir }}Source/*.dll ${{ env.outDir }}
copy ${{ env.buildDir }}Source/*.exe ${{ env.outDir }}
- uses: actions/upload-artifact@v2
Expand Down
18 changes: 13 additions & 5 deletions .github/workflows/windows_msys_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
pull_request:

env:
GH_CACHE_KEY: 1
GH_CACHE_KEY: 5

jobs:
build:
Expand Down Expand Up @@ -40,6 +40,7 @@ jobs:
mingw-w64-${{matrix.env.arch}}-boost
mingw-w64-${{matrix.env.arch}}-lld
mingw-w64-${{matrix.env.arch}}-libbacktrace
mingw-w64-${{matrix.env.arch}}-libvpx
mingw-w64-${{matrix.env.arch}}-nasm
mingw-w64-${{matrix.env.arch}}-yasm
mingw-w64-${{matrix.env.arch}}-zlib
Expand All @@ -62,17 +63,21 @@ jobs:
wget https://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-2.0.4-win32-${{matrix.env.arch_zip}}.zip -O downloads/SDL2_mixer.zip
- name: ffmpeg -- download
if: steps.cache.outputs.cache-hit != 'true'
run: git clone --depth 1 --branch n4.3.3 https://git.ffmpeg.org/ffmpeg.git ffmpeg
run: git clone --depth 1 --branch n4.4.1 https://git.ffmpeg.org/ffmpeg.git ffmpeg
- name: ffmpeg -- configure
if: steps.cache.outputs.cache-hit != 'true'
run: |
./configure --enable-shared --prefix=/mingw${{matrix.env.bits}} \
--disable-everything \
--enable-swscale \
--enable-swresample \
--enable-zlib \
--enable-demuxer=avi,rawvideo \
--enable-decoder=png,bink,rawvideo \
--enable-parser=png \
--enable-libvpx \
--enable-libvorbis \
--enable-demuxer=avi,rawvideo,bink,matroska \
--enable-decoder=png,rawvideo,bink,binkaudio_dct,vorbis,opus,vp8,vp9 \
--enable-parser=png,vp9 \
--enable-filter=aresample,aformat \
--enable-protocol=file \
--disable-d3d11va \
--disable-dxva2 \
Expand Down Expand Up @@ -108,8 +113,11 @@ jobs:
cp /mingw${{matrix.env.bits}}/bin/libwinpthread-1.dll perimeter/bin/
cp /mingw${{matrix.env.bits}}/bin/libbacktrace-0.dll perimeter/bin/
cp /mingw${{matrix.env.bits}}/bin/avcodec-58.dll perimeter/bin/
cp /mingw${{matrix.env.bits}}/bin/avfilter-7.dll perimeter/bin/
cp /mingw${{matrix.env.bits}}/bin/avformat-58.dll perimeter/bin/
cp /mingw${{matrix.env.bits}}/bin/avutil-56.dll perimeter/bin/
cp /mingw${{matrix.env.bits}}/bin/swscale-5.dll perimeter/bin/
cp /mingw${{matrix.env.bits}}/bin/swresample-3.dll perimeter/bin/
cp /mingw${{matrix.env.bits}}/bin/zlib1.dll perimeter/bin/
cp /SDL2_image/SDL2_image.dll perimeter/bin/
cp /SDL2_image/libjpeg-9.dll perimeter/bin/
Expand Down
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ OPTION(OPTION_DEBUG_ASSERT "Enable debug assertions" OFF)
OPTION(OPTION_GPERFTOOLS "Link executable with gperftools for debugging" OFF)
OPTION(OPTION_HEADLESS "Enable headless mode (no window or rendering)" OFF)
OPTION(OPTION_DXVK "Use dxvk-native for D3D9 API in Linux" ON)
OPTION(OPTION_FFMPEG_MOVIES "Use FFMPEG to decode ingame movies" ON)

# Compiler detections
SET(MSVC_CL_BUILD OFF)
Expand Down Expand Up @@ -152,6 +153,15 @@ IF(FFMPEG_FOUND)
#FFMPEG is found
ADD_DEFINITIONS(-DPERIMETER_FFMPEG)
INCLUDE_DIRECTORIES(${FFMPEG_INCLUDE_DIRS})
IF(OPTION_FFMPEG_MOVIES)
ADD_DEFINITIONS(-DPERIMETER_FFMPEG_MOVIE)
INCLUDE_DIRECTORIES(${FFMPEG_LIBSWSCALE_INCLUDE_DIRS})
INCLUDE_DIRECTORIES(${FFMPEG_LIBAVFILTER_INCLUDE_DIRS})
ELSE()
MESSAGE("WARNING: Movies disabled!")
ENDIF()
ELSE()
MESSAGE("WARNING: FFMPEG not found!, movies unavailable!")
ENDIF()

#Required for more compilant floating point math
Expand Down
3 changes: 2 additions & 1 deletion INSTALL.eng.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ Experimental support, it uses dxvk-native for D3D9 API and some libraries to sup
- glsllang-tools (for DXVK which needs glslangValidator program)

Packages in Debian/Ubuntu: `build-essential ninja cmake meson libvulkan-dev glslang-tools lld cmake meson zlib1g-dev
libsdl2-dev libsdl2-image-dev libsdl2-net-dev libsdl2-mixer-dev libboost-dev libavcodec-dev libavformat-dev `
libsdl2-dev libsdl2-image-dev libsdl2-net-dev libsdl2-mixer-dev libboost-dev
libavcodec-dev libavformat-dev libavfilter-dev libswscale-dev`

### Instructions

Expand Down
6 changes: 5 additions & 1 deletion Source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ SET(perimeter_LINK_LIBS

IF(FFMPEG_FOUND)
SET(perimeter_LINK_LIBS ${perimeter_LINK_LIBS} ${FFMPEG_LIBRARIES})
IF(OPTION_FFMPEG_MOVIES)
SET(perimeter_LINK_LIBS ${perimeter_LINK_LIBS} ${FFMPEG_LIBSWSCALE_LIBRARIES} ${FFMPEG_LIBAVFILTER_LIBRARIES})
ENDIF()
ENDIF()

IF(NOT PERIMETER_WINDOWS)
Expand Down Expand Up @@ -50,6 +53,7 @@ IF(NOT PERIMETER_WINDOWS)
)
ENDIF()
#DXVK-native wrapper lib retrieval and building
#TODO change this to upstream once changes are merged
ExternalProject_Add(dxvk-native
GIT_REPOSITORY https://github.com/IonAgorria/dxvk-native
GIT_TAG "aed08f8e5f4b069514dc4068b91e624cd4e0a495"
Expand Down Expand Up @@ -166,7 +170,7 @@ SET(perimeter_SRCS ${perimeter_SRCS}
Game/CameraManager.cpp
Game/MonkManager.cpp
Game/MusicManager.cpp
Game/PlayBink.cpp
Game/VideoPlayer.cpp
Game/qd_textdb.cpp
Units/Economic.cpp
Game/Player.cpp
Expand Down
Loading

0 comments on commit a82516e

Please sign in to comment.