Skip to content

Commit

Permalink
Add ffmpeg download script
Browse files Browse the repository at this point in the history
  • Loading branch information
yncat committed Jan 4, 2024
1 parent 6b8aa28 commit a6b774b
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
11 changes: 10 additions & 1 deletion tools/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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()
Expand Down
12 changes: 12 additions & 0 deletions tools/downloadFFmpeg.py
Original file line number Diff line number Diff line change
@@ -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
21 changes: 21 additions & 0 deletions tools/ffmpegDownloader.py
Original file line number Diff line number Diff line change
@@ -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!")

0 comments on commit a6b774b

Please sign in to comment.