mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-19 21:10:12 +02:00
Merge pull request #5337 from IvanSavenko/ffmpeg_explicit
[1.6?] Explicit toggle for ffmpeg video player compilation
This commit is contained in:
commit
8d78bb1a82
@ -48,6 +48,7 @@ endif()
|
|||||||
option(ENABLE_CLIENT "Enable compilation of game client" ON)
|
option(ENABLE_CLIENT "Enable compilation of game client" ON)
|
||||||
option(ENABLE_ERM "Enable compilation of ERM scripting module" OFF)
|
option(ENABLE_ERM "Enable compilation of ERM scripting module" OFF)
|
||||||
option(ENABLE_LUA "Enable compilation of LUA 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_TRANSLATIONS "Enable generation of translations for launcher and editor" ON)
|
||||||
option(ENABLE_NULLKILLER_AI "Enable compilation of Nullkiller AI library" 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)
|
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()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
if (ENABLE_CLIENT)
|
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 REQUIRED)
|
||||||
find_package(SDL2_image REQUIRED)
|
find_package(SDL2_image REQUIRED)
|
||||||
|
@ -474,12 +474,11 @@ target_link_libraries(vcmiclientcommon PUBLIC
|
|||||||
vcmi SDL2::SDL2 SDL2::Image SDL2::Mixer SDL2::TTF
|
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
|
target_link_libraries(vcmiclientcommon PRIVATE
|
||||||
${ffmpeg_LIBRARIES}
|
${ffmpeg_LIBRARIES}
|
||||||
)
|
)
|
||||||
else()
|
|
||||||
target_compile_definitions(vcmiclientcommon PRIVATE DISABLE_VIDEO)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_include_directories(vcmiclientcommon PUBLIC
|
target_include_directories(vcmiclientcommon PUBLIC
|
||||||
|
@ -17,12 +17,14 @@ public:
|
|||||||
/// Load video from specified path
|
/// Load video from specified path
|
||||||
std::unique_ptr<IVideoInstance> open(const VideoPath & name, float scaleFactor) override
|
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;
|
return nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Extracts audio data from provided video in wav format
|
/// Extracts audio data from provided video in wav format
|
||||||
std::pair<std::unique_ptr<ui8[]>, si64> getAudio(const VideoPath & videoToOpen) override
|
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};
|
return {nullptr, 0};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
#include "StdInc.h"
|
#include "StdInc.h"
|
||||||
#include "CVideoHandler.h"
|
#include "CVideoHandler.h"
|
||||||
|
|
||||||
#ifndef DISABLE_VIDEO
|
#ifdef ENABLE_VIDEO
|
||||||
|
|
||||||
#include "ISoundPlayer.h"
|
#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)
|
std::unique_ptr<IVideoInstance> CVideoPlayer::open(const VideoPath & name, float scaleFactor)
|
||||||
{
|
{
|
||||||
|
logGlobal->trace("Opening video: %s", name.getOriginalName());
|
||||||
|
|
||||||
auto result = std::make_unique<CVideoInstance>();
|
auto result = std::make_unique<CVideoInstance>();
|
||||||
|
|
||||||
if (!result->openInput(name))
|
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)
|
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 audioPath = videoToOpen.toType<EResType::SOUND>();
|
||||||
AudioPath audioPathVideoDir = audioPath.addPrefix("VIDEO/");
|
AudioPath audioPathVideoDir = audioPath.addPrefix("VIDEO/");
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifndef DISABLE_VIDEO
|
#ifdef ENABLE_VIDEO
|
||||||
|
|
||||||
#include "../lib/Point.h"
|
#include "../lib/Point.h"
|
||||||
#include "IVideoPlayer.h"
|
#include "IVideoPlayer.h"
|
||||||
|
@ -42,6 +42,11 @@ target_include_directories(vcmiclient
|
|||||||
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
|
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if(ENABLE_VIDEO)
|
||||||
|
target_compile_definitions(vcmiclient PRIVATE ENABLE_VIDEO)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
target_sources(vcmiclient PRIVATE "VCMI_client.rc")
|
target_sources(vcmiclient PRIVATE "VCMI_client.rc")
|
||||||
set_target_properties(vcmiclient
|
set_target_properties(vcmiclient
|
||||||
@ -56,11 +61,6 @@ if(WIN32)
|
|||||||
endif()
|
endif()
|
||||||
target_compile_definitions(vcmiclient PRIVATE WINDOWS_IGNORE_PACKING_MISMATCH)
|
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
|
# TODO: very hacky, find proper solution to copy AI dlls into bin dir
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
add_custom_command(TARGET vcmiclient POST_BUILD
|
add_custom_command(TARGET vcmiclient POST_BUILD
|
||||||
|
@ -314,7 +314,7 @@ int main(int argc, char * argv[])
|
|||||||
CSH = new CServerHandler();
|
CSH = new CServerHandler();
|
||||||
|
|
||||||
// Initialize video
|
// Initialize video
|
||||||
#ifdef DISABLE_VIDEO
|
#ifndef ENABLE_VIDEO
|
||||||
CCS->videoh = new CEmptyVideoPlayer();
|
CCS->videoh = new CEmptyVideoPlayer();
|
||||||
#else
|
#else
|
||||||
if (!settings["session"]["headless"].Bool() && !vm.count("disable-video"))
|
if (!settings["session"]["headless"].Bool() && !vm.count("disable-video"))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user