ossrs / srs

SRS is a simple, high-efficiency, real-time video server supporting RTMP, WebRTC, HLS, HTTP-FLV, SRT, MPEG-DASH, and GB28181.

Home Page:https://ossrs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to prevent audio streaming from buffering data?

zsk008 opened this issue · comments

  1. Use srs_aac_raw_publish to push the stream and use srs_play to play it. Close the publish, connect using play, and print out a frame of data first.
String onStatus
Object (1 items)
    Property 'code' String NetStream.Data.Start
[2019-01-18 17:26:01.35] Audio packet id=0/0.0/0.0, type=Audio, dts=44, pts=44, ndiff=0, diff=0, size=4, AAC(22KHz,16bit,Stereo,SH)

Why does SRS need to cache this frame of data? Can it be not cached? Because if we use srs_audio_raw_publish to push G711U stream, the encoding information will change. The player will first receive a frame of AAC data, and the subsequent data will be G711U. This will cause decoding issues.

TRANS_BY_GPT3

Tested nginx-rtmp-module, there is no issue with the test.

TRANS_BY_GPT3

I replied in issue 301: In this situation, if we use the rtmp protocol, the first frame dumped is always cache_sh_audio, which will affect the decoding afterwards. Now, I have fixed it.

 if (ds && cache_sh_audio && (ret = consumer->enqueue(cache_sh_audio, atc, jitter_algorithm)) != ERROR_SUCCESS) {
        srs_error("dispatch audio sequence header failed. ret=%d", ret);
        return ret;

Commenting it out can solve this problem, but will it affect HLS? Is there a better solution?

TRANS_BY_GPT3

This is the cache for the sequence header, which can be cleared when stopping the streaming. Take some time to check if it is well compatible with the browser.

TRANS_BY_GPT3