amr-如何在网页上直接播放

10次阅读

共计 2622 个字符,预计需要花费 7 分钟才能阅读完成。

在线播放方式

amr

alex374/amr-player 库

github: https://github.com/alex374/am…

<!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>

融云 IM 音频库

使用融云的库 https://www.rongcloud.cn/docs…

示例代码:https://blog.csdn.net/hanglov…

amr-wb

格式

amr 有三种文件格式

  • amr-nb
  • amr-wb
  • amr-wb+

arm-nb

AMR
也就是 arm 文件格式。
语音带宽范围:300-3400Hz,8KHz 采样,早期版本。

arm-wb

AMR WideBand
语音带宽范围:50-7000Hz,16KHz 采样,占用内存更大,话音更加自然、舒适和易于分辨。

arm-wb+

采样速率是在 16~48 kHz 之间。这使得它的语音带宽更宽 (24 kHz)

如何查看

通过文件内容

文件头格式:

AMR 文件支持单声道和多声道。单声道和多声道的文件头是不同的。

单声道:

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: 表示当前文件中含有几个声道。

通过 ffprobe 查看

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

正文完
 0