Open sinkinben opened 9 months ago
At this point the library only handles 1 or 2 channels, although it would probably wouldn't be too hard to fix that.
However, the reason I probably never implemented that is that I have never heard of the format supporting more than 2 channels. For example, if I try to encode a multichannel WAV file into adpcm_ima_wav
using FFmpeg
I get this message:
[adpcm_ima_wav @ 0x62c5a626c980] only stereo or mono is supported
Of course it would be possible to just force a higher number of channels, but the resulting files probably would not be playable by any existing software. Have you seen multichannel IMA ADPCM files in the wild? What do you have in mind?
Thanks!
This is my testing command with ffmpeg
:
> ./ffmpeg -i /e/workspace/temp-tuanjie/Assets/test6.wav -f wav -acodec adpcm_ima_wav ./adpcm-multi-channels.wav
Input #0, wav, from 'E:/workspace/temp-tuanjie/Assets/test6.wav':
Duration: 00:00:05.84, bitrate: 4233 kb/s
Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, 5.1, s16, 4233 kb/s
File './adpcm-multi-channels.wav' already exists. Overwrite? [y/N] y
Stream mapping:
Stream #0:0 -> #0:0 (pcm_s16le (native) -> adpcm_ima_wav (native))
Press [q] to stop, [?] for help
Output #0, wav, to './adpcm-multi-channels.wav':
Metadata:
ISFT : Lavf60.20.100
Stream #0:0: Audio: adpcm_ima_wav ([17][0][0][0] / 0x0011), 44100 Hz, stereo, s16p, 352 kb/s
Metadata:
encoder : Lavc60.38.100 adpcm_ima_wav
[out#0/wav @ 000002257a65ac40] video:0KiB audio:254KiB subtitle:0KiB other streams:0KiB global headers:0KiB muxing overhead: 0.036141%
size= 254KiB time=00:00:05.83 bitrate= 356.6kbits/s speed= 394x
It seems that ffmpeg
will map 6 channels to 2 channels, but the stereo output file will lose the LEF sound effect.
However, I think it's more reasonable to keep the number of channels unchanged
The test6.wav
is downloaded from https://www.mmsp.ece.mcgill.ca/Documents/AudioFormats/WAVE/Samples/Microsoft/6_Channel_ID.wav
Thanks for you reply :-D
For more details about 6 channels (aka 5.1 channel) audio file, refer to https://en.wikipedia.org/wiki/5.1_surround_sound
I just tried the latest FFmpeg and can verify what you're seeing: FFmpeg converts a 5.1 file to stereo and drops the LFE. This happens whether I try to generate an ADPCM wav file or a stereo PCM wav file. Dropping the LFE sounds like a bug to me, but often the FFmpeg devs will claim that's the intended behavior.
But the takeaway is that IMA ADPCM files can only be mono or stereo, so FFmpeg doesn't really have a choice but to mix down, and your suggestion of keeping the number of channels unchanged is impossible unless you want invalid ADPCM files that no software will play.
It would great if this supported, FMOD (dominant sound engine for games) for example support compressing multichannel (4.0 or 5.1) wav with IMA. Many sound editor including audacity and wavosaur support plain PCM multichannel wav but get stuck if IMA used.
I have noticed that:
and piece of code in
adpcm_converter
:Is it possible to support channels =
{4, 6, 8}
as input?