github: https://github.com/alex374/am...javascript
<!DOCTYPE html> <html> <head> <title> arm play</title> <script src="./amr-player-master/amrnb.js"></script> <script src="./amr-player-master/amrplayer.js"></script> <script type="text/javascript"> //var player = new AmrPlayer('./amr-player-master/1562307681788.amr'); var player = new AmrPlayer('./amr-player-master/13703524514_20190628184029.amr'); // chrome 禁止自動播放 改用手動播放 //player.play(); </script> </head> <body> <h1>amr play</h1> <button id="unmuteButton">start play</button> <script> unmuteButton.addEventListener('click', function() { player.play(); }); </script> </body> </html>
使用融雲的庫 https://www.rongcloud.cn/docs...html
示例代碼:https://blog.csdn.net/hanglov...java
https://github.com/sblandford...git
amr 有三種文件格式github
AMR
也就是 arm 文件格式。
語音帶寬範圍:300-3400Hz,8KHz採樣,早期版本。web
AMR WideBand
語音帶寬範圍: 50-7000Hz,16KHz採樣,佔用內存更大,話音更加天然、溫馨和易於分辨。chrome
採樣速率是在16~48 kHz之間。這使得它的語音帶寬更寬(24 kHz)ubuntu
文件頭格式:bash
AMR 文件支持單聲道和多聲道。單聲道和多聲道的文件頭是不一樣的。ide
單聲道:
AMR-NB文件頭: "#!AMRn" (or 0x2321414d520a in hexadecimal)(引號內的部分)
AMR-WB 文件頭:"#!AMR-WBn" (or 0x2321414d522d57420a in hexadecimal).(引號內)
多聲道:
多聲道的文件頭包含一個magic number和32bit channle description域。
AMR-NB 的magic number:"#!AMR_MC1.0n"
(or 0x2321414d525F4D43312E300a in hexadecimal).
AMR-WB的magic number:"#!AMR-WB_MC1.0n"
(or 0x2321414d522d57425F4D43312E300a in hexadecimal).
32bit的channel description域的定義以下:
其中 reserved bits必須爲0, CHAN:表示當前文件中含有幾個聲道。
root@51e7052bc967:/var/www/# ffprobe ./1562327664267_1.amr ffprobe version 4.0.2 Copyright (c) 2007-2018 the FFmpeg developers built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.9) 20160609 configuration: --enable-shared --enable-libmp3lame --disable-x86asm libavutil 56. 14.100 / 56. 14.100 libavcodec 58. 18.100 / 58. 18.100 libavformat 58. 12.100 / 58. 12.100 libavdevice 58. 3.100 / 58. 3.100 libavfilter 7. 16.100 / 7. 16.100 libswscale 5. 1.100 / 5. 1.100 libswresample 3. 1.100 / 3. 1.100 [amr @ 0xb19ac0] Estimating duration from bitrate, this may be inaccurate Input #0, amr, from './1562327664267_1.amr': Duration: 00:00:05.06, bitrate: 12 kb/s Stream #0:0: Audio: amr_nb (samr / 0x726D6173), 8000 Hz, mono, flt root@51e7052bc967:/var/www/# ffprobe ./18772355686_20190701164242.amr ffprobe version 4.0.2 Copyright (c) 2007-2018 the FFmpeg developers built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.9) 20160609 configuration: --enable-shared --enable-libmp3lame --disable-x86asm libavutil 56. 14.100 / 56. 14.100 libavcodec 58. 18.100 / 58. 18.100 libavformat 58. 12.100 / 58. 12.100 libavdevice 58. 3.100 / 58. 3.100 libavfilter 7. 16.100 / 7. 16.100 libswscale 5. 1.100 / 5. 1.100 libswresample 3. 1.100 / 3. 1.100 [amr @ 0x17f9ac0] Estimating duration from bitrate, this may be inaccurate Input #0, amr, from './18772355686_20190701164242.amr': Duration: 00:04:44.34, bitrate: 13 kb/s Stream #0:0: Audio: amr_wb (sawb / 0x62776173), 16000 Hz, mono, flt