Sample Header Ad - 728x90

How to detect real sample size and number of channels in WAV file?

11 votes
3 answers
25991 views
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?
Asked by landroni (11586 rep)
Dec 22, 2014, 12:19 AM
Last activity: Apr 29, 2020, 08:48 PM