Last active
July 22, 2019 21:14
-
-
Save DouglasAntunes/8acbaf1620b68a4c52a3abf72d27fa07 to your computer and use it in GitHub Desktop.
This script fixes the header of .igz and .snd audio files from Crash Team Racing Nitro-Fueled and to be possible to extract the audio with fsb_aud_extr tool.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
This script fixes the header of .igz and .snd audio files from Crash Team Racing Nitro-Fueled | |
and to be possible to extract the audio with fsb_aud_extr tool. Tested with the files from Switch release. | |
Fix Header of .igz and .snd files from a "files" folder located on the same folder of this script | |
WARNING: This script overwrites the original files located on files folder. | |
Folder Structure | |
-headerFix.py :This Script (Can be other name too) | |
-files\ :Input and Output Folder | |
""" | |
from os import listdir | |
from os.path import isfile, join, dirname, splitext | |
currentScriptPath = join(dirname(__file__), "files") | |
fileList = [ | |
f for f in listdir(currentScriptPath) if isfile(join(currentScriptPath, f)) | |
] | |
for file in fileList: | |
_, ext = splitext(file) | |
if ext == ".snd" or ext == ".igz": | |
print("Fixing header of", file, "...") | |
filenameWithFolderPath = join("files", file) | |
with open(filenameWithFolderPath, mode="rb") as originalBinaryFile: | |
originalBinaryFile.seek(0, 2) | |
numOfBytes = originalBinaryFile.tell() | |
for i in range(numOfBytes): | |
originalBinaryFile.seek(i) | |
sample = originalBinaryFile.read(4) | |
if sample == b"\x46\x53\x42\x35": | |
# print("Header found at", str(i)) | |
originalBinaryFile.seek(i) | |
data = originalBinaryFile.read(numOfBytes - i) | |
with open(filenameWithFolderPath, mode="wb") as outputBinaryFile: | |
outputBinaryFile.write(data) | |
break | |
print("\nDone.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment