PDA

View Full Version : How to properly compress FMOD vorbis audio


Masquerade
26-02-2022, 14:38
How to properly compress FMOD vorbis audio

Good evening everyone. I will not spend too long writing up this one since I detailed a lot in the WWise guide.

Like I noted in my guide for WWise audio, the WAV version of FMOD can be compressed with MSC just fine. FSB files contain OGG audio or WAV (and in some cases, both). OGGs, when done correctly, can be compressed with Oggre, saving you some space.

Here is the guide for how to properly compress FMOD audio. Part credits go to sowwyitsanalt for helping dig up some of these tools to help with the process.

Guide

Step 1: if you have an FMOD .bank file


Dump the bank to an fsb file using BankDumper (https://www.fileforums.com/showpost.php?p=495874&postcount=57).
BankDumper Master.bank Master.FSB

Step 2: now that you have a file that starts with FSB5 header



Download the attachment from below - "Python-FSB5.7z". This is a modified version of this library (https://github.com/HearthSim/python-fsb5) used to dump FMOD audio into playable OGGs and WAVs. Thanks to anadius for the modifications.
Extract the 7z.
Install Python if you do not have it installed, you will need it to run the script.
Open a command window in the folder containing your bank
Run: extract.py "<fsb file>" -o "<output folder"
extract.py Master.FSB -o Master
Pray that it works. If you get an error message, I would stop using this bank and move on, but it's up to you.


Step 3: Building the big ogg file


Use Bincat (https://aluigi.altervista.org/mytoolz/bincat.zip) by Aluigi to concatenate the oggs in the output folder into a single file. If there are wavs, concatenate them into a separate file.

bincat Master\*.ogg Master.TMP
bincat Master\*.wav Master.TMP2


Step 4: OGG to FMOD


At this point, we are working on our recompression steps. Use oggvorbis2fsb5 (https://github.com/uyjulian/oggvorbis2fsb5) to turn your big ogg file into an FMOD audio file.
oggvorbis2fsb5 Master.TMP Master.DAT
This tool will crash if any non OGG data is in the big file, so this is why we separate our wavs. If you have any wav data, use Bincat to combine the output from oggvorbis2fsb5 with the WAV TMP file you made earlier.
bincat Master.DAT Master.TMP2 Master.FSB_NEW


Step 5: Make a patch to the original bank


Depending on your output from step 4, you will either have a DAT file or a FSB_NEW file. You can now use XDelta or HDiffZ to make a patch from this file to the original bank. See how small it is!

If you use this method for installation, follow step 4 after extracting your archive to build the FMOD compatible data then instead of making the patch, apply the patch you made in step 5 to restore the original file.


https://i.ibb.co/98Wg1bG/Capture.png

Hopefully you now understand the process of compressing FMOD audio.

Referring to the above method, Master.TMP will be able to be compressed with oggre leading to smaller size than if you ran LZMA or whatever over the BANK.

This method is hit and miss, since there can be frequent errors with the python script. It isn't perfect.

If you would like a visual example, with screenshots and demonstration on a sample bank, please let me know and I shall provide.

L33THAK0R
06-04-2022, 18:53
Has anyone else encountered/attempted to apply this method to a "*.fsb" file present amongst a selection of "*.bank* files? I'm currently attempting to do so with the title "Hades" and have unfortunately had little success. Rebuilding the extracted Vorbis OGG audio files into a generated "*.tmp" fails, crashing "bincat", which I assume is likely due to the ~20,000 files extracted. Attempting to create 2 seperate ".tmp" files and manually merging them also seems to not be possible however further experimentation is required to discern whether the methods employed are at fault rather than the concept itself. I believe figuring out a viable solution is important for this title as the "VO.fsb" makes up for 655 MB out of the total 1.09 GB of FMOD audio containers present.

Masquerade
07-04-2022, 00:04
"VO.fsb" makes up for 655 MB out of the total 1.09 GB of FMOD audio containers present.

Please may you upload this file and send it to me? I would love to take a look.

fabrieunko
28-06-2022, 23:27
Hello, I try your tutorial but I have this message on all the files I test. Is this normal?

extract.py VO_FR.FSB -o VO_FR
Traceback (most recent call last):
File "F:\fmod\extract.py", line 131, in <module>
main()
File "F:\fmod\extract.py", line 127, in main
exit(app.run(sys.argv[1:]))
File "F:\fmod\extract.py", line 120, in run
with open(fname, 'rb') as f:
PermissionError: [Errno 13] Permission denied: 'VO_FR.FSB'


and if I directly indicate the name of the fsb file I have this message


f:\fmod>extract.py VO_FR.dat -o VO_FR
Traceback (most recent call last):
File "F:\fmod\extract.py", line 131, in <module>
main()
File "F:\fmod\extract.py", line 127, in main
exit(app.run(sys.argv[1:]))
File "F:\fmod\extract.py", line 121, in run
self.handle_file(f)
File "F:\fmod\extract.py", line 110, in handle_file
for sample_fakepath, sample_name, sample_data in self.read_samples(fakepath_prefix, fsb, ext):
File "F:\fmod\extract.py", line 86, in read_samples
yield sample_fakepath, sample.name, fsb.rebuild_sample(sample)
File "F:\fmod\fsb5\__init__.py", line 211, in rebuild_sample
from . import vorbis
File "F:\fmod\fsb5\vorbis.py", line 12, in <module>
vorbis = load_lib('vorbis')
File "F:\fmod\fsb5\utils.py", line 76, in load_lib
raise LibraryNotFoundException("Could not load the library %r" % (names[0]))
fsb5.utils.LibraryNotFoundException: Could not load the library 'vorbis'

Masquerade
29-06-2022, 00:53
Put libogg.dll and libvorbis.dll from that archive in System32. That's how I fixed this.

wareck
14-04-2024, 07:38
Hello
I follow this guide but I've got some but I'm having trouble finalizing the project...

What I've done:
file.bank => extract FSB file with quickbms
PythonFSB5=>extract all .ogg file
bincat to concatenate all .ogg file

now i do not understand that :
if I use oggvorb2fsb on this file I have a very small gain durring compression almost nothing
If i use oggre I have a very high gain , but crc error when I unpack file...

for now if I do this
file.bank => extract FSB file with quickbms
PythonFSB5=> extract all .ogg files
bincat => one big file
oggvorb2fsb5 => one big encoded file
hdiffpatch between original.bank and my new file
compress encoded file + diff file

during unpack
hpatchz encoded + diff file => restore my original file.bank

It works but very small ratio gain in conversion...

thanks for your help

regards

Masquerade
14-04-2024, 13:34
If i use oggre I have a very high gain , but crc error when I unpack file...

Use another hdiff patch from the decoded data from oggre_dec.exe to the concatenated ogg files. That hdiff patch should be tiny. Don't use oggre under freearc if you get a CRC fail.