1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-17 20:58:07 +02:00

Merge pull request #5337 from IvanSavenko/ffmpeg_explicit

[1.6?] Explicit toggle for ffmpeg video player compilation
This commit is contained in:
Ivan Savenko 2025-01-29 12:01:35 +02:00 committed by GitHub
commit 8d78bb1a82
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 21 additions and 12 deletions

View File

@ -48,6 +48,7 @@ endif()
option(ENABLE_CLIENT "Enable compilation of game client" ON)
option(ENABLE_ERM "Enable compilation of ERM scripting module" OFF)
option(ENABLE_LUA "Enable compilation of LUA scripting module" OFF)
option(ENABLE_VIDEO "Enable video support using ffmpeg" ON)
option(ENABLE_TRANSLATIONS "Enable generation of translations for launcher and editor" ON)
option(ENABLE_NULLKILLER_AI "Enable compilation of Nullkiller AI library" ON)
option(ENABLE_MINIMAL_LIB "Build only core parts of vcmi library that are required for game lobby" OFF)
@ -479,8 +480,11 @@ if(NOT FORCE_BUNDLED_MINIZIP)
endif()
endif()
if (ENABLE_CLIENT)
find_package(ffmpeg COMPONENTS avutil swscale avformat avcodec swresample)
if (ENABLE_VIDEO)
find_package(ffmpeg REQUIRED COMPONENTS avutil swscale avformat avcodec swresample)
endif()
find_package(SDL2 REQUIRED)
find_package(SDL2_image REQUIRED)

View File

@ -474,12 +474,11 @@ target_link_libraries(vcmiclientcommon PUBLIC
vcmi SDL2::SDL2 SDL2::Image SDL2::Mixer SDL2::TTF
)
if(ffmpeg_LIBRARIES)
if(ENABLE_VIDEO)
target_compile_definitions(vcmiclientcommon PRIVATE ENABLE_VIDEO)
target_link_libraries(vcmiclientcommon PRIVATE
${ffmpeg_LIBRARIES}
)
else()
target_compile_definitions(vcmiclientcommon PRIVATE DISABLE_VIDEO)
endif()
target_include_directories(vcmiclientcommon PUBLIC

View File

@ -17,12 +17,14 @@ public:
/// Load video from specified path
std::unique_ptr<IVideoInstance> open(const VideoPath & name, float scaleFactor) override
{
logGlobal->debug("Failed to open video. Reason: video support disabled in build");
return nullptr;
};
/// Extracts audio data from provided video in wav format
std::pair<std::unique_ptr<ui8[]>, si64> getAudio(const VideoPath & videoToOpen) override
{
logGlobal->debug("Failed to open video. Reason: video support disabled in build");
return {nullptr, 0};
};
};

View File

@ -10,7 +10,7 @@
#include "StdInc.h"
#include "CVideoHandler.h"
#ifndef DISABLE_VIDEO
#ifdef ENABLE_VIDEO
#include "ISoundPlayer.h"
@ -671,6 +671,8 @@ std::pair<std::unique_ptr<ui8 []>, si64> CAudioInstance::extractAudio(const Vide
std::unique_ptr<IVideoInstance> CVideoPlayer::open(const VideoPath & name, float scaleFactor)
{
logGlobal->trace("Opening video: %s", name.getOriginalName());
auto result = std::make_unique<CVideoInstance>();
if (!result->openInput(name))
@ -687,6 +689,8 @@ std::unique_ptr<IVideoInstance> CVideoPlayer::open(const VideoPath & name, float
std::pair<std::unique_ptr<ui8[]>, si64> CVideoPlayer::getAudio(const VideoPath & videoToOpen)
{
logGlobal->trace("Opening video: %s", videoToOpen.getOriginalName());
AudioPath audioPath = videoToOpen.toType<EResType::SOUND>();
AudioPath audioPathVideoDir = audioPath.addPrefix("VIDEO/");

View File

@ -9,7 +9,7 @@
*/
#pragma once
#ifndef DISABLE_VIDEO
#ifdef ENABLE_VIDEO
#include "../lib/Point.h"
#include "IVideoPlayer.h"

View File

@ -42,6 +42,11 @@ target_include_directories(vcmiclient
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
)
if(ENABLE_VIDEO)
target_compile_definitions(vcmiclient PRIVATE ENABLE_VIDEO)
endif()
if(WIN32)
target_sources(vcmiclient PRIVATE "VCMI_client.rc")
set_target_properties(vcmiclient
@ -56,11 +61,6 @@ if(WIN32)
endif()
target_compile_definitions(vcmiclient PRIVATE WINDOWS_IGNORE_PACKING_MISMATCH)
if(NOT ffmpeg_LIBRARIES)
target_compile_definitions(vcmiclient PRIVATE DISABLE_VIDEO)
endif()
# TODO: very hacky, find proper solution to copy AI dlls into bin dir
if(MSVC)
add_custom_command(TARGET vcmiclient POST_BUILD

View File

@ -314,7 +314,7 @@ int main(int argc, char * argv[])
CSH = new CServerHandler();
// Initialize video
#ifdef DISABLE_VIDEO
#ifndef ENABLE_VIDEO
CCS->videoh = new CEmptyVideoPlayer();
#else
if (!settings["session"]["headless"].Bool() && !vm.count("disable-video"))