Ren'Py The cruncher for my needs

Playstorepers

Member
May 24, 2020
160
79
Hey everyone,

I was just wondering what the "best" cruncher for my purpose is:

So far I tested this one:
https://f95zone.to/threads/cruncher-renpy-rpgm-mv-game-compactor-v0-4-1-bas.10227/
And I was very happy with it.

However I was very unhappy with the loss of audio quality, which is unavoidable, if you want to crunch soundfiles, of course.

So what I'm looking for is a cruncher, that can do same thing with the audio files , that the cruncher above can do: Change mp3-files to ogg files, without fucking over the extension name, so it's still a .mp3, so my game can recognize it.
But I just want the conversion to ogg, without the extra compression of audioloss.
The saved space of simply being an ogg-file, is what I'm looking for.

Thank you in advance.
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,581
2,219
Whilst Cruncher is designed to do the whole "compression" thing, it is only a script file which joins together a series of other tools.

If you have a look at the RPGMCruncher-x64-0.4.1.bat file, it's only a (somewhat complex) DOS batch file.

Taking it apart, if you pick 2. Audio Files, it jumps to a label called :audio.
From there, it processes certain types of file using a program called ffmpeg.exe using very specific parameters.

In order:

"mp3" ... ffmpeg.exe -i "%%a" -map_metadata -1 -codec:a libmp3lame -qscale:a 7 -vn "%%~dpa%%~na".temp."
"wav" ... ffmpeg.exe -i "%%a" -map_metadata -1 -codec:a libmp3lame -qscale:a 7 -vn "%%~dpa%%~na".temp."
"ogg" ... ffmpeg.exe -i "%%a" -codec:a libvorbis -qscale:a 3 "%%~dpa%%~na".temp."

Then it does some clever stuff, I can't really follow that goes looking for any matching filenames and runs ffmpeg with the command line options of it's choice. I'm sure some of it is creating some temporary file which is now a .ogg file - and then deletes the original .mp3, .wav or .ogg file before renaming the temporary file to be the old name.

So....

A couple of things...

Firstly, if you can follow the DOS batch file language with a little more patience than I have right now - you can probably get it to rename the newly created temporary file to be .ogg rather than it's original name.

Secondly... all those ffmpeg parameters could be changed.

A quick google search, and I found :
... which shows alternative command lines like : ffmpeg -i input.wav -codec:a libmp3lame -qscale:a 2 output.mp3
... and then a table which explains that -qscale:a 7 is the equivalent of perhaps 80-120 kbit/s. But by changing that 7 to a 4 or 3... the bitrate (and I presume quality) goes up to nearer 140-195 kbit/s.

My point is that because the batch file is just a plain text script file... you can alter it. Find those ffmpeg lines and swap those 7's to 4's (and the libmp3lame to libvorbis)... and you'll end up with better output quality audio files.
Or you could forget the script file and enter ffmpeg commands yourself, with different parameters.

It doesn't look like there's an easy way to NOT rename files. You could alter the line:
ren "%%~dpa%%~na".temp.%filetype% "%%~na.%filetype%"
... to be...
ren "%%~dpa%%~na".temp.%filetype% "%%~na.ogg" instead.

But since the :process is a common label used all over the place, it would break things for the processing of video or images. I'm sure there's a way around it... but I'm officially making that "not my problem".

Edit: Now I look back at the website I linked... it seems that -codec:a libmp3lame is actually recoding all the mp3 and wav files into .mp3 and the .ogg files to 112 kb/s .ogg files. For .ogg you'd need an ffmpeg command with the parameters to use either the vorbis or libvorbis codec libraries.

I just tested this : ffmpeg -i testfile.mp3 -c:a libvorbis -q:a 3 -vn d:\testfile.ogg and it converted a 256kb/s MP3 to a 112kb/s OGG file.
(-q:a 3 was 112kb/s, -q:a 4 was 128kb/s, -q:a 5 was 160kb/s and -q:a 2 was 96kb/s,).

From what I can see, -map_metadata -1 is pretty much "remove the mp3 metadata"... which isn't relevant if you're recoding to vorbis anyway.
 
Last edited:

Playstorepers

Member
May 24, 2020
160
79
Dude thank you so much for your bigass answer. I'm going to look into it.

And I'm not looking to rename all my files to .ogg.

I want them to be in the vorbis-format while retaining their filename (most of them are .mp3) , so I don't have to change my entire code.

But I really thank you for your answer and I'm going to look into it.
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,369
15,286
Whilst Cruncher is designed to do the whole "compression" thing, it is only a script file which joins together a series of other tools.
Must also be remembered that it's a tool that is intended to do heavy compression. Its role isn't to just reduce the size, but to drastically reduce it, in order for members to play an update despite mega limitations, bandwidth limitations, speed limitations and/or hard drive space limitations.
Therefore, it's not really a tool that a developer should use as it. For an official "lite version", each file should be took independently since some can support a heavy compression factor, while other would looks ugly even with a median compression.
 
  • Like
Reactions: Playstorepers

Meushi

Well-Known Member
Aug 4, 2017
1,146
12,728
I was just wondering what the "best" cruncher for my purpose is
Therefore, it's not really a tool that a developer should use as it. For an official "lite version", each file should be took independently since some can support a heavy compression factor, while other would looks ugly even with a median compression.
Obviously for the best optimization results follow AON's advice.

If you don't have the patience for that, then I'd suggest trying YAC. I've not used it, but according to the features:
Original file extensions are preserved
...
Quality is customizable with 3 presets: High, Medium, and Low.
You can adjust quality levels even more using the "custom" option.
 
  • Like
Reactions: Playstorepers

hngg

Compress All The Things!
Modder
Donor
Compressor
May 26, 2019
576
2,465
BAS's cruncher is very aggressive on the audio compression. He chose a target bitrate of 32k, which is fine for speach but very low for music. It's clear his first priority was file size. YAC's "low" preset is set to 48k which is still a noticeable amount of compression, but decent enough to where you won't say "wow, that sounds like shit". The higher presets give progressively better quality sound, of course. As with all compression, the better quality files you start with, the better they will be after compression.
 
  • Like
Reactions: Playstorepers