From 1e29d44d7d25f3eab703a500451b9bbb1cb3dc5a Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Fri, 21 May 2021 12:02:16 +0200 Subject: [PATCH] Add ffmpeg and fix video import --- ScreenPlay/CMakeLists.txt | 14 +++++++++++ ScreenPlay/app.cpp | 2 +- ScreenPlay/src/createimportvideo.cpp | 8 +++++-- ScreenPlayWallpaper/Wallpaper.qml | 3 ++- Tools/Readme.md | 15 ++++++++++++ Tools/download_ffmpeg.py | 36 ++++++++++++++++++++++++++++ 6 files changed, 74 insertions(+), 4 deletions(-) create mode 100644 Tools/Readme.md create mode 100644 Tools/download_ffmpeg.py diff --git a/ScreenPlay/CMakeLists.txt b/ScreenPlay/CMakeLists.txt index 19fadd25..c41ff9b5 100644 --- a/ScreenPlay/CMakeLists.txt +++ b/ScreenPlay/CMakeLists.txt @@ -145,4 +145,18 @@ if(APPLE) XCODE_ATTRIBUTE_EXECUTABLE_NAME ${PROJECT_NAME} ) + + add_custom_command( + TARGET ${PROJECT_NAME} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${CMAKE_CURRENT_SOURCE_DIR}/../Common/ffmpeg/ffmpeg + ${CMAKE_BINARY_DIR}/bin/ScreenPlay.app/Contents/MacOS/ ) + + add_custom_command( + TARGET ${PROJECT_NAME} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${CMAKE_CURRENT_SOURCE_DIR}/../Common/ffmpeg/ffprobe + ${CMAKE_BINARY_DIR}/bin/ScreenPlay.app/Contents/MacOS/ ) + + endif() diff --git a/ScreenPlay/app.cpp b/ScreenPlay/app.cpp index dc0c4051..e3b12b3d 100644 --- a/ScreenPlay/app.cpp +++ b/ScreenPlay/app.cpp @@ -220,7 +220,7 @@ void App::exit() */ bool App::loadSteamPlugin() { - const bool isDebug = true; + bool isDebug = true; #ifdef QT_NO_DEBUG isDebug = false; diff --git a/ScreenPlay/src/createimportvideo.cpp b/ScreenPlay/src/createimportvideo.cpp index 3db4ad62..0c60835d 100644 --- a/ScreenPlay/src/createimportvideo.cpp +++ b/ScreenPlay/src/createimportvideo.cpp @@ -39,8 +39,12 @@ CreateImportVideo::CreateImportVideo(const QString& videoPath, const QString& ex m_codec = codec; m_process = std::make_unique(this); - m_ffprobeExecutable = QApplication::applicationDirPath() + "/ffprobe" + ScreenPlayUtil::executableEnding(); - m_ffmpegExecutable = QApplication::applicationDirPath() + "/ffmpeg" + ScreenPlayUtil::executableEnding(); + QString fileEnding ; +#ifdef Q_OS_WIN + fileEnding = ScreenPlayUtil::executableEnding(); +#endif + m_ffprobeExecutable = QApplication::applicationDirPath() + "/ffprobe" + fileEnding; + m_ffmpegExecutable = QApplication::applicationDirPath() + "/ffmpeg" + fileEnding ; } /*! diff --git a/ScreenPlayWallpaper/Wallpaper.qml b/ScreenPlayWallpaper/Wallpaper.qml index 0f25062f..7428eb5c 100644 --- a/ScreenPlayWallpaper/Wallpaper.qml +++ b/ScreenPlayWallpaper/Wallpaper.qml @@ -136,7 +136,8 @@ Rectangle { source: { if (Qt.platform.os === "windows") return Qt.resolvedUrl("file:///" + Wallpaper.windowsDesktopProperties.wallpaperPath); - + else + return "" } Component.onCompleted: { diff --git a/Tools/Readme.md b/Tools/Readme.md new file mode 100644 index 00000000..a9afdecd --- /dev/null +++ b/Tools/Readme.md @@ -0,0 +1,15 @@ +## Tools + +This folder contains serveral python tools to help with development: +#### setup.py +- Installs third party dependencies for all platforms +#### build.py +- Build ScreenPlay locally +#### clang_format.py +- Invokers clang-format for all .cpp and .h files +#### qdoc.py +- Builds documentation for all projects into Docs/html +#### download_ffmpeg.py +- Donwload ffmpeg for macos only for now +#### qml_format.py +- Calls qmlformat for all qml files diff --git a/Tools/download_ffmpeg.py b/Tools/download_ffmpeg.py new file mode 100644 index 00000000..29780640 --- /dev/null +++ b/Tools/download_ffmpeg.py @@ -0,0 +1,36 @@ +import zipfile +from urllib.request import urlopen +import os + + +def download_and_extract(file_base_path, name): + print("Download: ", name) + + download_server_base_url = 'https://evermeet.cx/ffmpeg/' + filedata = urlopen(download_server_base_url + name) + datatowrite = filedata.read() + path_and_filename = os.path.join(file_base_path, name) + + print("Save tmp file: ", path_and_filename) + with open(path_and_filename, 'wb') as f: + f.write(datatowrite) + + extraction_path = os.path.join(file_base_path, "../Common/ffmpeg") + + print("Extract to:", extraction_path) + with zipfile.ZipFile(path_and_filename,"r") as zip_ref: + zip_ref.extractall(extraction_path) + + print("Delete tmp file: ", path_and_filename) + os.remove(path_and_filename) + +ffmpeg_7zip_name = 'ffmpeg-4.4.zip' +ffprobe_7zip_name = 'ffprobe-4.4.zip' +current_path = os.path.join(os.path.abspath(os.getcwd()),"") +extraction_path = os.path.abspath(os.path.join(current_path, "../Common/ffmpeg")) + +if not os.path.exists(extraction_path): + os.makedirs(extraction_path) + +download_and_extract(current_path, ffmpeg_7zip_name) +download_and_extract(current_path, ffprobe_7zip_name)