How to play amr directly on Web page

Keywords: Javascript github Ubuntu

amr online play

Alex374 / AMR player library

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 forbids auto play to manual play
        //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>

Rongyun IM audio library

Use the library of rongyun https://www.rongcloud.cn/docs...

Example code: https://blog.csdn.net/hanglov...

AMR WB online play

https://github.com/sblandford...

format

amr has three file formats

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

arm-nb

AMR
That is, the arm file format.
Voice bandwidth range: 300-3400Hz, 8KHz sampling, earlier version.

arm-wb

AMR WideBand
Voice bandwidth range: 50-7000Hz, 16KHz sampling, larger memory occupation, more natural, comfortable and easy to distinguish voice.

arm-wb+

The sampling rate is between 16 and 48 kHz. This makes its voice bandwidth wider (24 kHz)

How to view

Through document content

File header format:

AMR files support mono and multichannel. The file headers for mono and multichannel are different.

Mono:

AMR-NB header: "ා! Amrn" (or 0x2321414d520a in hexadecimal) (part in quotation marks)

AMR-WB header: "ා! AMR-WBn" (or 0x2321414d522d57420a in hexadecimal) (in quotation marks)

Multichannel:

The multichannel header contains a magic number and 32bit channel description field.

magic number of AMR-NB: "ා! AMR ﹐ mc1.0n"

(or 0x2321414d525F4D43312E300a in hexadecimal).

magic number of AMR-WB: "ා! Amr-wb{mc1.0n"

(or 0x2321414d522d57425F4D43312E300a in hexadecimal).

The 32bit channel description field is defined as follows:

Where reserved bits must be 0, CHAN: indicates that the current file contains several channels.

View through 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

Posted by Joeddox on Wed, 30 Oct 2019 11:09:14 -0700