rewrote zsh scripts for asset extract
This commit is contained in:
parent
cb0a4d8bf6
commit
1f26e8a9ce
2 changed files with 135 additions and 34 deletions
|
|
@ -138,12 +138,67 @@ def process_voice(cache_dir, extract_dir, update_dir):
|
|||
os.path.join(cache_dir, "Android/Asset/Sound/Voice"),
|
||||
os.path.join(extract_dir, "Voice"),
|
||||
)
|
||||
subprocess.run(
|
||||
os.path.join("TODO", "update_voice.zsh"), shell=True, cwd=extract_dir
|
||||
)
|
||||
copy_tree(
|
||||
os.path.join(extract_dir, "voice_extracted"), os.path.join(update_dir, "Voice")
|
||||
)
|
||||
|
||||
from_dir = "Voice"
|
||||
to_dir = "Voice_Extracted"
|
||||
acb_prefix = "_vgmt_acb_ext"
|
||||
|
||||
pool = get_pool()
|
||||
|
||||
with change_cwd(extract_dir):
|
||||
os.makedirs(to_dir, exist_ok=True)
|
||||
|
||||
to_del = glob("{}/**/*.wav".format(from_dir), recursive=True)
|
||||
to_del.extend(glob("{}/**/*.hca".format(from_dir), recursive=True))
|
||||
for file in to_del:
|
||||
os.remove(file)
|
||||
|
||||
acb_files = [file for file in glob("{}/*.acb".format(from_dir))]
|
||||
acb_cmd = get_dotnet_cmd("acb_extract.exe")
|
||||
run_program(acb_files, cmd=acb_cmd)
|
||||
|
||||
hca_files = [
|
||||
file for file in glob("{}/**/*.hca".format(from_dir), recursive=True)
|
||||
]
|
||||
run_program(hca_files, cmd="clHCA")
|
||||
|
||||
basenames = [os.path.splitext(os.path.basename(file))[0] for file in acb_files]
|
||||
char_secs = [basename.split("_", maxsplit=1) for basename in basenames]
|
||||
for cs in char_secs:
|
||||
char = cs[0]
|
||||
sec = str(cs[1]) if len(cs) == 2 else ""
|
||||
os.makedirs(os.path.join(to_dir, char, sec), exist_ok=True)
|
||||
wav_files = glob(
|
||||
"{}/{}_{}/**/*.wav".format(from_dir, acb_prefix, "_".join(cs)),
|
||||
recursive=True,
|
||||
)
|
||||
partial_ffmpeg_cmd = functools.partial(run_program, cmd="ffmpeg")
|
||||
|
||||
wav_cmds = [
|
||||
[
|
||||
"-i",
|
||||
os.path.abspath(file),
|
||||
"-acodec",
|
||||
"libopus",
|
||||
"-ab",
|
||||
"192k",
|
||||
"-af",
|
||||
"aresample=48000",
|
||||
os.path.abspath(
|
||||
"{}/{}/{}/{}.opus".format(
|
||||
to_dir,
|
||||
char,
|
||||
sec,
|
||||
os.path.splitext(os.path.basename(file))[0],
|
||||
)
|
||||
),
|
||||
"-n",
|
||||
]
|
||||
for file in wav_files
|
||||
]
|
||||
pool.map(partial_ffmpeg_cmd, wav_cmds)
|
||||
|
||||
copy_tree(os.path.join(extract_dir, to_dir), os.path.join(update_dir, "Voice"))
|
||||
|
||||
|
||||
def process_movie(cache_dir, extract_dir, update_dir):
|
||||
|
|
@ -151,12 +206,59 @@ def process_movie(cache_dir, extract_dir, update_dir):
|
|||
os.path.join(cache_dir, "Common/Asset/Movie"),
|
||||
os.path.join(extract_dir, "Movie"),
|
||||
)
|
||||
subprocess.run(
|
||||
os.path.join("TODO", "update_movie.zsh"), shell=True, cwd=extract_dir
|
||||
)
|
||||
|
||||
from_dir = "Movie"
|
||||
to_dir = "Movie_Extracted"
|
||||
|
||||
pool = get_pool()
|
||||
|
||||
with change_cwd(extract_dir):
|
||||
os.makedirs(to_dir, exist_ok=True)
|
||||
|
||||
to_del = glob("{}/**/*.adx".format(from_dir), recursive=True)
|
||||
to_del.extend(glob("{}/**/*.m2v".format(from_dir), recursive=True))
|
||||
for file in to_del:
|
||||
os.remove(file)
|
||||
|
||||
movie_paths = [
|
||||
os.path.abspath(os.path.splitext(file)[0])
|
||||
for file in glob("{}/*.usm".format(from_dir))
|
||||
if not os.path.basename(file).startswith("mini_radio")
|
||||
]
|
||||
|
||||
usm_files = [[path + ".usm"] for path in movie_paths]
|
||||
usm_cmd = get_dotnet_cmd("usm_extract.exe")
|
||||
partial_usm_cmd = functools.partial(run_program, cmd=usm_cmd)
|
||||
pool.map(partial_usm_cmd, usm_files)
|
||||
|
||||
partial_ffmpeg_cmd = functools.partial(run_program, cmd="ffmpeg")
|
||||
mux_cmds = [
|
||||
[
|
||||
"-i",
|
||||
path + ".adx",
|
||||
"-i",
|
||||
path + ".m2v",
|
||||
"-c:a",
|
||||
"libopus",
|
||||
"-b:a",
|
||||
"196k",
|
||||
"-af",
|
||||
"aresample=48000",
|
||||
"-c:v",
|
||||
"libvpx",
|
||||
"-b:v",
|
||||
"1M",
|
||||
"-threads",
|
||||
"1",
|
||||
os.path.abspath("{}/{}.webm".format(to_dir, os.path.basename(path))),
|
||||
"-n",
|
||||
]
|
||||
for path in movie_paths
|
||||
]
|
||||
pool.map(partial_ffmpeg_cmd, mux_cmds)
|
||||
|
||||
copy_tree(
|
||||
os.path.join(extract_dir, "movie_extracted"),
|
||||
os.path.join(update_dir, "Asset/Movie"),
|
||||
os.path.join(extract_dir, to_dir), os.path.join(update_dir, "Asset", "Movie")
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -15,33 +15,32 @@ from xdudata.asset_extract import process_se, process_bgm, process_voice, proces
|
|||
def update_all(
|
||||
cache_dir, update_dir, translation_dir, extract_dir, languages,
|
||||
):
|
||||
# TODO uncomment
|
||||
# print("Checking tool availability")
|
||||
# validate_tools()
|
||||
#
|
||||
# print("Cleaning cache")
|
||||
# cleanup_cache(cache_dir)
|
||||
#
|
||||
# print("Copying images")
|
||||
# copy_images(cache_dir, update_dir)
|
||||
#
|
||||
# print("Processing TSV files")
|
||||
# update_tsv(cache_dir, update_dir, extract_dir, translation_dir, languages)
|
||||
#
|
||||
# print("Processing Quest Json files")
|
||||
# diva.quest.update_missions(extract_dir, translation_dir, languages)
|
||||
print("Checking tool availability")
|
||||
validate_tools()
|
||||
|
||||
print("Cleaning cache")
|
||||
cleanup_cache(cache_dir)
|
||||
|
||||
print("Copying images")
|
||||
copy_images(cache_dir, update_dir)
|
||||
|
||||
print("Processing TSV files")
|
||||
update_tsv(cache_dir, update_dir, extract_dir, translation_dir, languages)
|
||||
|
||||
print("Processing Quest Json files")
|
||||
diva.quest.update_missions(extract_dir, translation_dir, languages)
|
||||
|
||||
print("Processing Sound Effects")
|
||||
process_se(cache_dir, extract_dir, update_dir)
|
||||
|
||||
# print("Processing BGM")
|
||||
# process_bgm(cache_dir, extract_dir, update_dir)
|
||||
#
|
||||
# print("Processing voices")
|
||||
# process_voice(cache_dir, extract_dir, update_dir)
|
||||
#
|
||||
# print("Processing movies - this might take forever")
|
||||
# process_movie(cache_dir, extract_dir, update_dir)
|
||||
print("Processing BGM")
|
||||
process_bgm(cache_dir, extract_dir, update_dir)
|
||||
|
||||
print("Processing voices")
|
||||
process_voice(cache_dir, extract_dir, update_dir)
|
||||
|
||||
print("Processing movies - this might take forever")
|
||||
process_movie(cache_dir, extract_dir, update_dir)
|
||||
|
||||
|
||||
def validate_tools():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue