版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/glw0223/article/details/88069019
参考文档:https://blog.csdn.net/glw0223/article/details/88063489
分析文件1905_mono_2s.wav,文件下载地址
ffprobe分析
gaoliwendeMacBook-Pro:testfile gaoliwen$ ffprobe 1905_mono_2s.wav
ffprobe version 4.1 Copyright (c) 2007-2018 the FFmpeg developers
built with Apple LLVM version 10.0.0 (clang-1000.11.45.5)
configuration: --prefix=/usr/local/Cellar/ffmpeg/4.1_1 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gpl --enable-libmp3lame --enable-libopus --enable-libsnappy --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-lzma --enable-opencl --enable-videotoolbox
libavutil 56. 22.100 / 56. 22.100
libavcodec 58. 35.100 / 58. 35.100
libavformat 58. 20.100 / 58. 20.100
libavdevice 58. 5.100 / 58. 5.100
libavfilter 7. 40.101 / 7. 40.101
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 3.100 / 5. 3.100
libswresample 3. 3.100 / 3. 3.100
libpostproc 55. 3.100 / 55. 3.100
Input #0, wav, from '1905_mono_2s.wav':
Metadata:
encoder : Lavf58.20.100
Duration: 00:00:02.05, bitrate: 256 kb/s
Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 16000 Hz, 1 channels, s16, 256 kb/s
ls查看大小
gaoliwendeMacBook-Pro:testfile gaoliwen$ ls -lat 1905_mono_2s.wav
-rw-r--r--@ 1 gaoliwen staff 65614 Mar 1 17:23 1905_mono_2s.wav
共65614字节。
hex help工具查看
文件头
中间忽略
文件尾
0x10040 + 0xd + 0x1 = 0x1004e 转成十进制是65614字节
具体(字段)分析
字节偏移 | 字节 | 描述 |
0-3bytes | 52 49 46 46 | ChunkID,RIFF |
4-7bytes | 46 00 01 00 | ChunkSize,长度,0x 01 00 46 表示后面的字节长度(不包括本身),也就是0x010046 加上8个字节就是文件大小 |
8-11bytes | 57 41 56 45 | Format,WAVE(前12字节是The RIFF Header Chunk,https://tools.ietf.org/html/draft-ema-vpim-wav-00#section-2.2.1) |
12-15bytes | 66 6d 74 20 | Subchunk1ID,fmt,FourCC格式,最后一个自己补充 |
16-19bytes | 10 00 00 00 | Subchunk1Size,格式块长度,0x 10,即16个字节长度。就是后面的01 00 01 00 80 3e 00 00 00 7d 00 00 02 00 10 00 |
20-21bytes | 01 00 | AudioFormat,0x01,即PCM 脉冲编码调制格式 |
22-23bytes | 01 00 | NumChannels,0x01,即单声道。(单声道为 1,立体声或双声道为 2) |
24-27bytes | 80 3e 00 00 | SampleRate,0x 3e 80转成十进制是16000,就是16k采样率 |
28-31bytes | 00 7d 00 00 | ByteRate,0x 7d 00是32000,即1声道x16k采样率x16位采样/8 = (该数值为:声道数×采样频率×每样本的数据位数/8),和ffprobe分析的256kbps是相同的 |
32-33bytes | 02 00 | BlockAlign,采样帧大小。该数值为:声道数×位数/8。即每个采样2个字节 |
34-35bytes | 10 00 | BitsPerSample:0x 00 10,即16位采样(12-35字节,共24字节,是The Format Chunk,https://tools.ietf.org/html/draft-ema-vpim-wav-00#section-2.2.2) |
36-39bytes | 4c 49 53 54 | LIST |
40-43bytes | 1a 00 00 00 | size,即0x 1a,从下一个字节开始26个字节 |
44-69bytes | 共26个字节 | |
70-73bytes | 64 61 74 61 | data, https://tools.ietf.org/html/draft-ema-vpim-wav-00#section-2.2.3 |
74-77bytes | 00 00 01 00 | 数据长度0x 01 00 00,即65536字节的音频裸数据, |
78-65613bytes | 共65536个字节 | PCM数据 |