Gravemind2401 / Reclaimer

A Halo game file explorer
GNU General Public License v3.0
74 stars 16 forks source link

Incorrect conversion of (Halo 2) XBOX 4-bit IMA ADPCM due to ffmpeg #71

Open RevOcelotMGS opened 4 weeks ago

RevOcelotMGS commented 4 weeks ago

When using ffmpeg to convert audio files encoded in the XBOX 4-bit IMA ADPCM format, the resulting output contains noticeable audible noise. This occurs when re-encoding to any format - even WAV. The quality degradation is significant, and the issue persists across multiple versions of ffmpeg. This problem appears to be specific to how ffmpeg handles this codec, and is not necessarily an issue with Reclaimer itself or it handles the re-encoding process, as I am unable to find any workarounds with ffmpeg that alleviate this issue.

The output should be a clean file without any added noise, preserving the original audio quality. However, the resulting file contains audible noise,

As an example, I'm providing a screenshot showing conversion of an Xbox IMA file from another game to FLAC using vgmstream (Flyaround_06), and then the same file in ffmpeg. You will be able to observe that the frequencies in the ffmpeg output have much more audible noise present. This same issue occurs in Halo 2.

image

Given this issue, I recommend switching from ffmpeg as a re-encoder to vgmstream for converting these files - specifically, vgmstream-cli. vgmstream handles these conversions with 100% clean output, preserving the original audio quality without the noise observed in ffmpeg. It should also support most (if not all) of the extracted sound tags from each Halo game, should sound extraction be added for these games down the line.

Gravemind2401 commented 1 week ago

This looks promising, albeit less flexible than ffmpeg. My main concern is that it doesn't appear to support receiving the file input via stdin. With ffmpeg, Reclaimer streams the sound data directly into the ffmpeg process, but with vgmstream it looks like it requires the input to be a file path. In a large batch extract this would create significant overhead since Reclaimer would have to write the data to disk for every permutation of every sound tag, then make sure it removes the temporary file(s) after conversion is done.