安防音频

音频编码相关的调研:

1、 默认情况下将使用PCMU (G711u)。PCMU和PCMA能给你带来比较好的音质效果但同时也将占用比较大的带宽。
如果你的网络情况不是很好,你可以选择G723或者G729编码,这两个编码可以提供比较好的音质的情况下占
用比较少的带宽资源。如果你的带宽充足的情况下,你也可以选择G722宽带编码,它将带给你逼真的音质效果。

G711 实际占用带宽 每线90.4kbit/s 100线并发占用 9Mbps
G729 实际占用带宽 每线34.4kbit/s 100线并发占用 3.4Mbps
G723 实际占用带宽 每线22.9kbit/s 100线并发占用 2.2Mbps

带宽=包长度×每秒包数
=包长度×(1/打包周期)
=(Ethernet头+IP头+UDP头+RTP头+有效载荷)×(1/打包周期)
=(208bit +160bit+64bit+96bit +有效载荷)×(1/打包周期)
=(528bit+(打包周期(秒)×每秒的比特数))×(1/打包周期)
=( 528 / 打包周期 ) + 每秒比特数

SRS发布音频raw的API定义:
/**
* write an audio raw frame to srs.
* not similar to h.264 video, the audio never aggregated, always
* encoded one frame by one, so this api is used to write a frame.
*
* @param sound_format Format of SoundData. The following values are defined:
* 0 = Linear PCM, platform endian
* 1 = ADPCM
* 2 = MP3
* 3 = Linear PCM, little endian
* 4 = Nellymoser 16 kHz mono
* 5 = Nellymoser 8 kHz mono
* 6 = Nellymoser
* 7 = G.711 A-law logarithmic PCM
* 8 = G.711 mu-law logarithmic PCM
* 9 = reserved
* 10 = AAC
* 11 = Speex
* 14 = MP3 8 kHz
* 15 = Device-specific sound
* Formats 7, 8, 14, and 15 are reserved.
* AAC is supported in Flash Player 9,0,115,0 and higher.
* Speex is supported in Flash Player 10 and higher.
* @param sound_rate Sampling rate. The following values are defined:
* 0 = 5.5 kHz
* 1 = 11 kHz
* 2 = 22 kHz
* 3 = 44 kHz
* @param sound_size Size of each audio sample. This parameter only pertains to
* uncompressed formats. Compressed formats always decode
* to 16 bits internally.
* 0 = 8-bit samples
* 1 = 16-bit samples
* @param sound_type Mono or stereo sound
* 0 = Mono sound
* 1 = Stereo sound
* @param timestamp The timestamp of audio.
*
* @example /trunk/research/librtmp/srs_aac_raw_publish.c
* @example /trunk/research/librtmp/srs_audio_raw_publish.c
*
* @remark for aac, the frame must be in ADTS format.
* @see aac-mp4a-format-ISO_IEC_14496-3+2001.pdf, page 75, 1.A.2.2 ADTS
* @remark for aac, only support profile 1-4, AAC main/LC/SSR/LTP,
* @see aac-mp4a-format-ISO_IEC_14496-3+2001.pdf, page 23, 1.5.1.1 Audio object type
*
* @see https://github.com/simple-rtmp-server/srs/issues/212
* @see E.4.2.1 AUDIODATA of video_file_format_spec_v10_1.pdf
*
* @return 0, success; otherswise, failed.
*/
extern int srs_audio_write_raw_frame(srs_rtmp_t rtmp,
char sound_format, char sound_rate, char sound_size, char sound_type,
char* frame, int frame_size, u_int32_t timestamp
);

    /**
    * whether aac raw data is in adts format,
    * which bytes sequence matches '1111 1111 1111'B, that is 0xFFF.
    * @param aac_raw_data the input aac raw data, a encoded aac frame data.
    * @param ac_raw_size the size of aac raw data.
    *
    * @reamrk used to check whether current frame is in adts format.
    *       @see aac-mp4a-format-ISO_IEC_14496-3+2001.pdf, page 75, 1.A.2.2 ADTS
    * @example /trunk/research/librtmp/srs_aac_raw_publish.c
    *
    * @return 0 false; otherwise, true.
    */
    extern srs_bool srs_aac_is_adts(char* aac_raw_data, int ac_raw_size);

    /**
    * parse the adts header to get the frame size,
    * which bytes sequence matches '1111 1111 1111'B, that is 0xFFF.
    * @param aac_raw_data the input aac raw data, a encoded aac frame data.
    * @param ac_raw_size the size of aac raw data.
    *
    * @return failed when <=0 failed; otherwise, ok.
    */
    extern int srs_aac_adts_frame_size(char* aac_raw_data, int ac_raw_size);   
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值