Skip to content

Commit

Permalink
Remove functionality to download FFmpeg builds
Browse files Browse the repository at this point in the history
  • Loading branch information
rsubtil committed Apr 7, 2024
1 parent a59c1c3 commit ebed70f
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 52 deletions.
4 changes: 0 additions & 4 deletions SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ env_ffmpeg = env.Clone()

FFMPEG_DUMMY = "thirdparty/ffmpeg/LICENSE.txt"

ffmpeg_download_action = ffmpeg_download.ffmpeg_download_builder(
env_ffmpeg, FFMPEG_DUMMY, "gdextension_build/ffmpeg_download.py"
)

module_obj = []

excluded = []
Expand Down
1 change: 0 additions & 1 deletion gdextension_build/SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ else:
)

FFMPEG_DUMMY = "../thirdparty/ffmpeg/LICENSE.txt"
ffmpeg_download_action = ffmpeg_download.ffmpeg_download_builder(env, FFMPEG_DUMMY, "ffmpeg_download.py")
ffmpeg_install_action = ffmpeg_download.ffmpeg_install(env, f"#{addon_platform_dir}", "../thirdparty/ffmpeg")
env.Depends(sources, env.Install(addon_base_dir, "ffmpeg.gdextension"))
license_install_action = env.InstallAs(f"{addon_base_dir}LICENSE-ffmpeg.txt", FFMPEG_DUMMY)
Expand Down
47 changes: 0 additions & 47 deletions gdextension_build/ffmpeg_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import tarfile
import SCons

FFMPEG_DOWNLOAD_WIN64 = "https://github.com/EIRTeam/FFmpeg-Builds/releases/download/autobuild-2023-07-24-08-52/ffmpeg-N-111611-g5b11ee9429-win64-lgpl-godot.tar.xz"
FFMPEG_DOWNLOAD_LINUX64 = "https://github.com/EIRTeam/FFmpeg-Builds/releases/download/autobuild-2023-07-24-08-52/ffmpeg-N-111611-g5b11ee9429-linux64-lgpl-godot.tar.xz"
ffmpeg_versions = {
"avcodec": "60",
"avfilter": "9",
Expand All @@ -30,38 +28,6 @@ def get_ffmpeg_install_sources(env, source_dir):
else:
return [os.path.join(source_dir, f"bin/{lib}-{version}.dll") for lib, version in ffmpeg_versions.items()]


def get_download_url(env):
if env["platform"] == "linuxbsd" or env["platform"] == "linux":
FFMPEG_DOWNLOAD_URL = FFMPEG_DOWNLOAD_LINUX64
else:
FFMPEG_DOWNLOAD_URL = FFMPEG_DOWNLOAD_WIN64
return FFMPEG_DOWNLOAD_URL


def download_ffmpeg(target, source, env):
dst = os.path.dirname(target[0].get_path())
if os.path.exists(dst):
shutil.rmtree(dst)

FFMPEG_DOWNLOAD_URL = get_download_url(env)

local_filename, headers = urllib.request.urlretrieve(FFMPEG_DOWNLOAD_URL)

def rewrite_subfolder_paths(tf, common_path):
l = len(common_path)
for member in tf.getmembers():
if member.path.startswith(common_path):
member.path = member.path[l:]
yield member

with tarfile.open(local_filename, mode="r") as f:
# Get the first folder
common_path = os.path.commonpath(f.getnames()) + "/"
f.extractall(dst, members=rewrite_subfolder_paths(f, common_path))
os.remove(local_filename)


def _ffmpeg_emitter(target, source, env):
target += get_ffmpeg_install_sources(env, os.path.dirname(target[0].get_path()))
if env["platform"] == "windows":
Expand Down Expand Up @@ -89,18 +55,5 @@ def _ffmpeg_emitter(target, source, env):

return target, source


def ffmpeg_download_builder(env, target, source):
bkw = {
"action": env.Run(download_ffmpeg, "Downloading FFMPEG library", False),
"target_factory": env.fs.Entry,
"source_factory": env.fs.Entry,
"emitter": _ffmpeg_emitter,
}

bld = SCons.Builder.Builder(**bkw)
return bld(env, target, source)


def ffmpeg_install(env, target, source):
return env.InstallAs(get_ffmpeg_install_targets(env, target), get_ffmpeg_install_sources(env, source))

0 comments on commit ebed70f

Please sign in to comment.