[Tutorial] How to save space in your Ren'Py game
Posted: Sat Aug 19, 2017 2:17 pm
These commands will allow you to reduce your game's space up to 90% without any script editing.
Change directory to your game's project directory first.
Please note that the original files will be deleted, so if you want the original files to be kept, copy the original files outside of your game's project directory.
You need GNU coreutils, GNU parallel, Perl, ffmpeg, and webp tools installed.
If you are running Windows, these can be installed from within Windows Subsystem for Linux.
Audio format (change any occurrence of ogg to your audio format):
These parameters are good enough for my use; however, if you want to play with the codec parameters, see the ffmpeg documentation.
Video format (change any occurrence of avi to your video format):
These parameters are good enough for my use; however, if you want to play with the codec parameters, see the ffmpeg documentation.
Lossless image format (change any occurrence of png to your lossless image format):
These parameters are good enough for my use; however, if you want to play with the codec parameters, see the cwebp documentation.
Lossy image format (change any occurrence of jpg to your lossy image format):
These parameters are good enough for my use; however, if you want to play with the codec parameters, see the cwebp documentation.
Change directory to your game's project directory first.
Please note that the original files will be deleted, so if you want the original files to be kept, copy the original files outside of your game's project directory.
You need GNU coreutils, GNU parallel, Perl, ffmpeg, and webp tools installed.
If you are running Windows, these can be installed from within Windows Subsystem for Linux.
Audio format (change any occurrence of ogg to your audio format):
Code: Select all
find . -name \*.ogg -print0 | parallel -0 --nice 19 ffmpeg -y -i {} -c:a libopus -b:a 64k -f webm {}.mka
find . -name \*.ogg.mka -exec rename -f 's/.ogg.mka$/.ogg/' {} +;
Video format (change any occurrence of avi to your video format):
Code: Select all
find . -name \*.avi -execdir ffmpeg -y -i {} -c:v libvpx-vp9 -pass 1 -b:v 1000K -threads 4 -speed 4 -tile-columns 6 -frame-parallel 1 -an -passlogfile {} -f webm /dev/null \;
find . -name \*.avi -execdir ffmpeg -i {} -c:v libvpx-vp9 -pass 2 -b:v 1000K -threads 4 -speed 1 -tile-columns 6 -frame-parallel 1 -auto-alt-ref 1 -lag-in-frames 25 -c:a libopus -b:a 64k -passlogfile {} {}.mkv \;
find . -name \*.log -delete
find . -name \*.avi.mkv -exec rename -f 's/.avi.mkv$/.avi/' {} +;
Lossless image format (change any occurrence of png to your lossless image format):
Code: Select all
find . -name \*.png -print0 | parallel -0 --nice 19 cwebp {} -lossless -o {}.webp \;
find . -name \*.png.webp -exec rename -f 's/.png.webp$/.png/' {} +;
Lossy image format (change any occurrence of jpg to your lossy image format):
Code: Select all
find . -name \*.jpg -print0 | parallel -0 --nice 19 cwebp {} -o {}.jpg \;
find . -name \*.jpg.webp -exec rename -f 's/.jpg.webp$/.jpg/' {} +;