scripts: add more asset configs

This commit is contained in:
sk1982 2024-03-12 19:22:10 -04:00
parent 55babd1dbf
commit 1dc3dbaf8d
8 changed files with 141 additions and 12 deletions

View File

@ -0,0 +1,14 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="PyPackageRequirementsInspection" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ignoredPackages">
<value>
<list size="1">
<item index="0" class="java.lang.String" itemvalue="scikit-image" />
</list>
</value>
</option>
</inspection_tool>
</profile>
</component>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptLibraryMappings">
<excludedPredefinedLibrary name="actaeon/server/node_modules" />
</component>
</project>

View File

@ -18,9 +18,14 @@ def run(event, func, args):
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--config', help='asset config', default='assets.yaml')
parser.add_argument('--processes', type=int, default=cpu_count(), help='number of processes to use')
parser.add_argument('--out-dir', '--output', help='output directory', default='../public/assets')
parser.add_argument('--config', help='asset config (default=assets.yaml)', default='assets.yaml')
parser.add_argument('--processes', type=int, default=cpu_count(), help=f'number of processes to use (default={cpu_count()})')
parser.add_argument('--out-dir', '--output-dir', '--output', '-o', help='output directory (default=../public/assets)', default='../public/assets')
parser.add_argument('--no-overwrite', '-n', help='don\'t overwrite exising files', action='store_true')
parser.add_argument('--no-music', help='don\'t process music files', action='store_true')
parser.add_argument('--no-audio', help='don\'t process other audio files', action='store_true')
parser.add_argument('--no-jackets', help='don\'t process jacket images', action='store_true')
parser.add_argument('--no-images', help='don\'t process other images', action='store_true')
subparsers = parser.add_subparsers(dest='game', help='game extracter to use', required=True)
extracters = get_extracters()
for name, extracter in extracters.items():

32
scripts/assets.fast.yaml Normal file
View File

@ -0,0 +1,32 @@
# produces decent quality files faster, at the expense of larger file sizes
# path to ffmpeg if it is not on the path
ffmpeg_path: 'ffmpeg'
# path to vgmstream if it is not on the path
# required for some audio conversions
# https://github.com/vgmstream/vgmstream
vgmstream_path: 'vgmstream-cli'
# options for music
music:
enable: true
extension: .opus
ffmpeg_args: ['-b:a', '64k']
# options for music jacket images
jackets:
enable: true
extension: .webp
ffmpeg_args: []
# options for other images
images:
enable: true
extension: .webp
ffmpeg_args: ['-preset', 'drawing']
# options for other audio
audio:
enable: true
extension: .opus
ffmpeg_args: [ '-b:a', '64k' ]

View File

@ -0,0 +1,32 @@
# produces decent quality files much faster, at the expense of greatly increased file sizes
# path to ffmpeg if it is not on the path
ffmpeg_path: 'ffmpeg'
# path to vgmstream if it is not on the path
# required for some audio conversions
# https://github.com/vgmstream/vgmstream
vgmstream_path: 'vgmstream-cli'
# options for music
music:
enable: true
extension: .opus
ffmpeg_args: ['-b:a', '64k']
# options for music jacket images
jackets:
enable: true
extension: .png
ffmpeg_args: []
# options for other images
images:
enable: true
extension: .png
ffmpeg_args: []
# options for other audio
audio:
enable: true
extension: .opus
ffmpeg_args: [ '-b:a', '64k' ]

View File

@ -0,0 +1,32 @@
# produces lossless files
# path to ffmpeg if it is not on the path
ffmpeg_path: 'ffmpeg'
# path to vgmstream if it is not on the path
# required for some audio conversions
# https://github.com/vgmstream/vgmstream
vgmstream_path: 'vgmstream-cli'
# options for music
music:
enable: true
extension: .flac
ffmpeg_args: []
# options for music jacket images
jackets:
enable: true
extension: .webp
ffmpeg_args: ['-lossless', '1']
# options for other images
images:
enable: true
extension: .webp
ffmpeg_args: ['-lossless', '1']
# options for other audio
audio:
enable: true
extension: .flac
ffmpeg_args: []

View File

@ -1,3 +1,5 @@
# produces small-sized, decent quality files at the expense of long encoding times
# path to ffmpeg if it is not on the path
ffmpeg_path: 'ffmpeg'
# path to vgmstream if it is not on the path
@ -14,13 +16,14 @@ music:
# options for music jacket images
jackets:
enable: true
extension: .webp
extension: .avif
ffmpeg_args: ['-c:v', 'libaom-av1', '-still-picture', '1', '-cpu-used', '2', '-pix_fmt:0', 'yuv420p']
# options for other images
images:
enable: true
extension: .webp
ffmpeg_args: ['-preset', 'drawing']
extension: .avif
ffmpeg_args: ['-map', '0', '-map', '0', '-filter:v:1', 'alphaextract', '-c:v', 'libaom-av1', '-still-picture', '1', '-cpu-used', '2', '-pix_fmt:0', 'yuv420p']
# options for other audio
audio:

View File

@ -13,7 +13,7 @@ from collections import defaultdict
class Extracter:
def __init__(self, *, config, out_dir, **kwargs):
def __init__(self, *, config, out_dir, no_overwrite, no_music, no_audio, no_jackets, no_images, **kwargs):
with open(config, 'r') as f:
self.config = yaml.safe_load(f)
self.music_enabled = self.config['music']['enable']
@ -22,6 +22,11 @@ class Extracter:
self.audio_enabled = self.config['audio']['enable']
self.out_dir = Path(out_dir)
self.tmp_dir = self.out_dir / 'tmp'
self.no_overwrite = no_overwrite
self.no_music = no_music
self.no_audio = no_audio
self.no_jackets = no_jackets
self.no_images = no_images
def get_tmp(self, ext='.dat'):
self.tmp_dir.mkdir(parents=True, exist_ok=True)
@ -76,7 +81,7 @@ class Extracter:
args = [
self.config['ffmpeg_path'],
'-y',
('-n' if self.no_overwrite else '-y'),
'-hide_banner',
'-loglevel',
'error',
@ -141,13 +146,13 @@ class Extracter:
raise NotImplementedError
def extract(self):
if self.jackets_enabled:
if self.jackets_enabled and not self.no_jackets:
yield from self.extract_jacket()
if self.images_enabled:
if self.images_enabled and not self.no_images:
yield from self.extract_images()
if self.music_enabled:
if self.music_enabled and not self.no_music:
yield from self.extract_music()
if self.audio_enabled:
if self.audio_enabled and not self.no_audio:
yield from self.extract_audio()
@staticmethod