mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
refine the overflow algorithm, prevent smaller piece.
This commit is contained in:
parent
d19dfa528e
commit
1d973e2178
2 changed files with 14 additions and 2 deletions
|
@ -542,6 +542,11 @@ bool SrsHlsMuxer::is_segment_overflow()
|
||||||
{
|
{
|
||||||
srs_assert(current);
|
srs_assert(current);
|
||||||
|
|
||||||
|
// to prevent very small segment.
|
||||||
|
if (current->duration < 2 * SRS_AUTO_HLS_SEGMENT_MIN_DURATION_MS) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// use N% deviation, to smoother.
|
// use N% deviation, to smoother.
|
||||||
double deviation = hls_ts_floor? SRS_HLS_FLOOR_REAP_PERCENT * deviation_ts * hls_fragment : 0.0;
|
double deviation = hls_ts_floor? SRS_HLS_FLOOR_REAP_PERCENT * deviation_ts * hls_fragment : 0.0;
|
||||||
srs_info("hls: dur=%.2f, tar=%.2f, dev=%.2fms/%dp, frag=%.2f",
|
srs_info("hls: dur=%.2f, tar=%.2f, dev=%.2fms/%dp, frag=%.2f",
|
||||||
|
@ -560,6 +565,11 @@ bool SrsHlsMuxer::is_segment_absolutely_overflow()
|
||||||
// @see https://github.com/winlinvip/simple-rtmp-server/issues/151#issuecomment-83553950
|
// @see https://github.com/winlinvip/simple-rtmp-server/issues/151#issuecomment-83553950
|
||||||
srs_assert(current);
|
srs_assert(current);
|
||||||
|
|
||||||
|
// to prevent very small segment.
|
||||||
|
if (current->duration < 2 * SRS_AUTO_HLS_SEGMENT_MIN_DURATION_MS) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// use N% deviation, to smoother.
|
// use N% deviation, to smoother.
|
||||||
double deviation = hls_ts_floor? SRS_HLS_FLOOR_REAP_PERCENT * deviation_ts * hls_fragment : 0.0;
|
double deviation = hls_ts_floor? SRS_HLS_FLOOR_REAP_PERCENT * deviation_ts * hls_fragment : 0.0;
|
||||||
srs_info("hls: dur=%.2f, tar=%.2f, dev=%.2fms/%dp, frag=%.2f",
|
srs_info("hls: dur=%.2f, tar=%.2f, dev=%.2fms/%dp, frag=%.2f",
|
||||||
|
|
|
@ -871,9 +871,10 @@ int SrsIngestSrsOutput::parse_message_queue()
|
||||||
|
|
||||||
SrsTsMessage* first_ts_msg = queue.begin()->second;
|
SrsTsMessage* first_ts_msg = queue.begin()->second;
|
||||||
SrsTsContext* context = first_ts_msg->channel->context;
|
SrsTsContext* context = first_ts_msg->channel->context;
|
||||||
|
bool cpa = context->is_pure_audio();
|
||||||
|
|
||||||
int nb_videos = 0;
|
int nb_videos = 0;
|
||||||
if (!context->is_pure_audio()) {
|
if (!cpa) {
|
||||||
std::multimap<int64_t, SrsTsMessage*>::iterator it;
|
std::multimap<int64_t, SrsTsMessage*>::iterator it;
|
||||||
for (it = queue.begin(); it != queue.end(); ++it) {
|
for (it = queue.begin(); it != queue.end(); ++it) {
|
||||||
SrsTsMessage* msg = it->second;
|
SrsTsMessage* msg = it->second;
|
||||||
|
@ -892,7 +893,8 @@ int SrsIngestSrsOutput::parse_message_queue()
|
||||||
}
|
}
|
||||||
|
|
||||||
// parse messages util the last video.
|
// parse messages util the last video.
|
||||||
while ((nb_videos > 1 || context->is_pure_audio()) && queue.size() > 0) {
|
while ((cpa && queue.size() > 1) || nb_videos > 1) {
|
||||||
|
srs_assert(!queue.empty());
|
||||||
std::multimap<int64_t, SrsTsMessage*>::iterator it = queue.begin();
|
std::multimap<int64_t, SrsTsMessage*>::iterator it = queue.begin();
|
||||||
|
|
||||||
SrsTsMessage* msg = it->second;
|
SrsTsMessage* msg = it->second;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue