From a6b774bcec76fcb206d0694fb8998756156d9fa5 Mon Sep 17 00:00:00 2001 From: Yukio Nozawa Date: Thu, 4 Jan 2024 22:48:40 +0900 Subject: [PATCH] Add ffmpeg download script --- tools/build.py | 11 ++++++++++- tools/downloadFFmpeg.py | 12 ++++++++++++ tools/ffmpegDownloader.py | 21 +++++++++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 tools/downloadFFmpeg.py create mode 100644 tools/ffmpegDownloader.py diff --git a/tools/build.py b/tools/build.py index 828c5a5..0232351 100644 --- a/tools/build.py +++ b/tools/build.py @@ -21,11 +21,13 @@ import urllib.request import zipfile + import diff_archiver import constants -from tools import bumpup + +from tools import bumpup, ffmpegDownloader class build: @@ -34,6 +36,10 @@ def __init__(self): appveyor = self.setAppVeyor() print("Starting build for %s(appveyor mode=%s)" % (constants.APP_NAME, appveyor)) + # FFmpegがなければダウンロードする + if not os.path.isfile("ffmpeg.exe"): + self.downloadFFmpeg() + # パッケージのパスとファイル名を決定 package_path = os.path.join("dist", os.path.splitext(os.path.basename(constants.STARTUP_FILE))[0]) if 'APPVEYOR_REPO_TAG_NAME' in os.environ: @@ -78,6 +84,9 @@ def __init__(self): self.makePackageInfo(archive_name, patch_name, build_filename) print("Build finished!") + def downloadFFmpeg(self): + ffmpegDownloader.downloadFFmpeg() + def runcmd(self,cmd): proc=subprocess.Popen(cmd.split(), shell=True, stdout=1, stderr=2) proc.communicate() diff --git a/tools/downloadFFmpeg.py b/tools/downloadFFmpeg.py new file mode 100644 index 0000000..7946174 --- /dev/null +++ b/tools/downloadFFmpeg.py @@ -0,0 +1,12 @@ +import os +import sys +sys.path.append(os.getcwd()) + +from tools import ffmpegDownloader + + +if os.path.isfile("ffmpeg.exe"): + print("ffmpeg.exe already exists!") +else: + ffmpegDownloader.downloadFFmpeg() +# end if diff --git a/tools/ffmpegDownloader.py b/tools/ffmpegDownloader.py new file mode 100644 index 0000000..625c672 --- /dev/null +++ b/tools/ffmpegDownloader.py @@ -0,0 +1,21 @@ +import urllib.request +import os +import shutil +import zipfile + +def downloadFFmpeg(): + ffmpegVersion = "6.1.1" + remoteFile = "ffmpeg-%s-full_build" % ffmpegVersion + url = "https://github.com/GyanD/codexffmpeg/releases/download/%s/%s.zip" % (ffmpegVersion, remoteFile) + print("Downloading FFmpeg from %s" % url) + urllib.request.urlretrieve(url, "ffmpeg.zip") + print("Extracting FFmpeg...") + with zipfile.ZipFile("ffmpeg.zip", "r") as zip: + zip.extract("%s/bin/ffmpeg.exe" % remoteFile) + # end with + print("moving ffmpeg.exe to current directory...") + shutil.move(os.path.join(remoteFile, "bin", "ffmpeg.exe"), "ffmpeg.exe") + print("removing temporary files...") + shutil.rmtree(remoteFile) + os.remove("ffmpeg.zip") + print("got ffmpeg!")