How to detect real sample size and number of channels in WAV file?
Solution 1
As pointed out in this question, an excellent utility for this task is MediaInfo.
MediaInfo is a convenient unified display of the most relevant technical and tag data for video and audio files.
geek@liv-inspiron:~$ mediainfo file.wav
General
Complete name : file.wav
Format : Wave
File size : 33.6 MiB
Duration : 3mn 19s
Overall bit rate mode : Constant
Overall bit rate : 1 411 Kbps
Audio
Format : DTS
Format/Info : Digital Theater Systems
Mode : 14
Format settings, Endianness : Little
Codec ID : 1
Duration : 3mn 19s
Bit rate mode : Constant
Bit rate : 1 411.2 Kbps
Channel(s) : 6 channels
Channel positions : Front: L C R, Side: L R, LFE
Sampling rate : 44.1 KHz
Bit depth : 24 bits
Compression mode : Lossy
Stream size : 33.6 MiB (100%)
This would confirm that the specific file is DTS with 6 channels, but interestingly that the sample size is actually 24 bits and strangely that the compression mode is lossy.
One can also use this utility via a GUI: mediainfo-gui
.
Solution 2
Looks like dts-wav. Many of these files have a header format ID which suggests PCM, but the actual byte stream is DTS. This explains the soxi output.
If you have a recent version (2007 or later) of ffmpeg/libavcodec installed, mplayer should be able to detect that and use the appropriate non-PCM codec.
The VLC output implies you have DTS with a 5.1 configuration (6 channels).
Related videos on Youtube
landroni
Updated on September 18, 2022Comments
-
landroni almost 2 years
I've got this wonderful conundrum with a WAV file, whereas I cannot detect it's actual sample size (i.e. how many bits are in a sample) and the number of channels.
geek@liv-inspiron:~$ soxi file.wav Input File : 'file.wav' Channels : 2 Sample Rate : 44100 Precision : 16-bit Duration : 00:03:19.56 = 8800596 samples = 14967 CDDA sectors File Size : 35.2M Bit Rate : 1.41M Sample Encoding: 16-bit Signed Integer PCM
MPlayer2 reports the following (but I can only hear noise):
geek@liv-inspiron:~$ mplayer file.wav MPlayer2 2.0-701-gd4c5b7f-2ubuntu2 (C) 2000-2012 MPlayer Team Playing file.wav. Detected file format: WAV / WAVE (Waveform Audio) (libavformat) [wav @ 0x7f21516c9600]max_analyze_duration reached [lavf] stream 0: audio (pcm_s16le), -aid 0 Load subtitles in . Selected audio codec: Uncompressed PCM [pcm] AUDIO: 44100 Hz, 2 ch, s16le, 1411.2 kbit/100.00% (ratio: 176400->176400) AO: [alsa] 44100Hz 2ch s16le (2 bytes per sample) Video: no video Starting playback...
While MPlayer outputs actual sound, and seems to detect a DTS format:
geek@liv-inspiron:~$ mplayer file.wav MPlayer 1.1-4.8 (C) 2000-2012 MPlayer Team Playing file.wav. libavformat version 54.20.3 (external) Audio only file format detected. Load subtitles in ./ ========================================================================== Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders libavcodec version 54.35.0 (external) AUDIO: 44100 Hz, 2 ch, floatle, 1411.2 kbit/50.00% (ratio: 176400->352800) Selected audio codec: [ffdca] afm: ffmpeg (FFmpeg DTS) ========================================================================== AO: [pulse] 44100Hz 2ch floatle (4 bytes per sample) Video: no video Starting playback...
And if I play it with VLC which also outputs actual sound, it reports:
Type: Audio Codec: DTS Audio (dts ) Channels: 3F2R/LFE Sample rate: 44100 Hz Bitrate: 1411 kb/s
Some quick math yields 1411 ∕ 44.1 ≈ 31.995465, which implies a 32-bit sample size. So which one is it: 16-bit or 32-bit? Or is it 16-bit per channel?
And how many channels does it have? 2 as in Stereo or 5 as in DTS? The info is again conflicting...
In other words, is there a tool that can accurately report the technical data for a WAV file, without getting confused by erroneous headers?
-
psusi over 9 yearsThere are two channels, hence it takes twice the bandwidth of a single channel.
-
landroni over 9 years@psusi The proposed answer suggests that it might be DTS 5.1, and it does seem to be that way. Does your comment still hold in that case? Thanks.
-
psusi over 9 yearsIn that case neither my comment, nor the question make sense since there is no relationship between sample size + rate, and the bit rate of a lossy compressor.
-
landroni over 9 years@psusi Not sure I follow. I'm dealing with a WAV file that seemingly contains a DTS stream... All the technical data in the question has been reported by various tools. I'm seeking a tool that can accurately report the technical data for the WAV file, without getting confused by erroneous headers.
-
-
Jan Waldmann over 9 yearspsusi is right, in that case it could also be the other way round. If playback on both players is possible, the situation can maybe be explained by a fallback in VLC.
-
landroni over 9 years@psusi Actually I am hearing just noise in MPlayer2... But it plays fine in VLC or in MPlayer. The latter also calls a DTS-related codec (see updated question), but even then for some reason MPlayer reports only 2 channels (instead of DTS 5 or 6)...
-
landroni over 9 years@psusi I found a utility that outputs the precise technical data that I was looking for. See accepted answer.