0

I used the following to extract mono l and r wavs from a 24-bit stereo wav file but the result is two 16-bit files:

ffmpeg -i stereo24bit.wav -map_channel 0.0.0 left.wav -map_channel 0.0.1 right.wav

What do I add to this or how do I change it to preserve the 24-bit depth of the original? Searching has not turned up an answer to this, some similar results but not what I am looking for.

Run5k
  • 16,463
  • 24
  • 53
  • 67

1 Answers1

1

i want to be copying and to avoid any re-encoding

-map_channel is an alias for the pan filter. You can't filter a stream and also stream copy it. However, since your input and output are PCM it doesn't really matter.

How do I preserve the 24-bit depth of the original?

Some encoders, such as flac, support multiple sample formats, and ffmpeg will automatically attempt to choose the highest depth. But the default encoder for .wav output is pcm_s16le, which is only 16-bit (refer to ffmpeg -h encoder=pcm_s16le), so in this case you need to manually provide the name of an encoder that supports 24-bit, such as pcm_s24le.

-map_channel

ffmpeg -i stereo24bit.wav -map_channel 0.0.0 -c:a pcm_s24le left.wav -map_channel 0.0.1 -c:a pcm_s24le right.wav

channelsplit

Or if you want to use the channelsplit filter which might be more intuitive than the legacy -map_channel option:

ffmpeg -i stereo24bit.wav -filter_complex "channelsplit=channel_layout=stereo:channels=FL|FR[left][right]" -map "[left]" -c:a pcm_s24le left.wav -map "[right]" -c:a pcm_s24le right.wav

Or in your particular case you can just use the channelsplit default values:

ffmpeg -i stereo24bit.wav -filter_complex "channelsplit[left][right]" -map "[left]" -c:a pcm_s24le left.wav -map "[right]" -c:a pcm_s24le right.wav

Verifying

You can add the -loglevel debug global option to view more details about the process:

[graph_0_in_0_0 @ 0x55be6dfc6e00] Setting 'sample_fmt' to value 's32
[auto_resampler_0 @ 0x55be6dfcab40] picking s32p out of 6 ref:s32
[auto_resampler_0 @ 0x55be6dfcab40] [SWR @ 0x55be6dfcb000] Using s32p internally between filters
[auto_resampler_0 @ 0x55be6dfcab40] ch:2 chl:stereo fmt:s32 r:44100Hz -> ch:2 chl:stereo fmt:s32p r:44100Hz
[auto_resampler_1 @ 0x55be6dfe0940] ch:1 chl:1 channels (FR) fmt:s32p r:44100Hz -> ch:1 chl:1 channels (FR) fmt:s32 r:44100Hz
llogan
  • 63,280