mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
refine hls, try to fix the hls ts corrupt problem.
This commit is contained in:
parent
828aadf858
commit
5a3cd235fd
4 changed files with 8 additions and 7 deletions
|
@ -758,7 +758,7 @@ int SrsHlsCache::write_video(SrsAvcAacCodec* codec, SrsHlsMuxer* muxer, int64_t
|
|||
// new segment when:
|
||||
// 1. base on gop.
|
||||
// 2. some gops duration overflow.
|
||||
if (cache->vf->key && muxer->is_segment_overflow()) {
|
||||
if (sample->frame_type == SrsCodecVideoAVCFrameKeyFrame && muxer->is_segment_overflow()) {
|
||||
if ((ret = reap_segment("video", muxer, cache->vf->dts)) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
|
@ -788,6 +788,7 @@ int SrsHlsCache::reap_segment(string log_desc, SrsHlsMuxer* muxer, int64_t segme
|
|||
}
|
||||
|
||||
// TODO: flush audio before or after segment?
|
||||
// TODO: fresh segment begin with audio or video?
|
||||
|
||||
// segment open, flush video first.
|
||||
if ((ret = muxer->flush_video(cache->af, cache->ab, cache->vf, cache->vb)) != ERROR_SUCCESS) {
|
||||
|
|
|
@ -233,10 +233,10 @@ extern int aac_sample_rates[];
|
|||
#define __SRS_AAC_SAMPLE_RATE_UNSET 15
|
||||
|
||||
// in ms, for HLS aac flush the audio
|
||||
#define SRS_CONF_DEFAULT_AAC_DELAY 100
|
||||
#define SRS_CONF_DEFAULT_AAC_DELAY 60
|
||||
|
||||
// max PES packets size to flush the video.
|
||||
#define SRS_AUTO_HLS_AUDIO_CACHE_SIZE 1024 * 1024
|
||||
#define SRS_AUTO_HLS_AUDIO_CACHE_SIZE 128 * 1024
|
||||
|
||||
/**
|
||||
* the FLV/RTMP supported audio sample size.
|
||||
|
|
|
@ -224,7 +224,7 @@ public:
|
|||
|
||||
if (first) {
|
||||
first = false;
|
||||
if (frame->key) {
|
||||
if (frame->write_pcr) {
|
||||
p[-1] |= 0x20; // Both Adaption and Payload
|
||||
*p++ = 7; // size
|
||||
*p++ = 0x50; // random access + PCR
|
||||
|
@ -399,7 +399,7 @@ SrsMpegtsFrame::SrsMpegtsFrame()
|
|||
{
|
||||
pts = dts = 0;
|
||||
pid = sid = cc = 0;
|
||||
key = false;
|
||||
write_pcr = false;
|
||||
}
|
||||
|
||||
string srs_ts_stream2string(SrsTsStream stream)
|
||||
|
@ -1971,7 +1971,7 @@ int SrsTsCache::cache_video(SrsAvcAacCodec* codec, int64_t dts, SrsCodecSample*
|
|||
vf->pts = vf->dts + sample->cts * 90;
|
||||
vf->pid = TS_VIDEO_PID;
|
||||
vf->sid = TS_VIDEO_AVC;
|
||||
vf->key = sample->frame_type == SrsCodecVideoAVCFrameKeyFrame;
|
||||
vf->write_pcr = sample->frame_type == SrsCodecVideoAVCFrameKeyFrame;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ public:
|
|||
int pid;
|
||||
int sid;
|
||||
int cc;
|
||||
bool key;
|
||||
bool write_pcr;
|
||||
|
||||
SrsMpegtsFrame();
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue