正在显示
2 个修改的文件
包含
14 行增加
和
2 行删除
@@ -542,6 +542,11 @@ bool SrsHlsMuxer::is_segment_overflow() | @@ -542,6 +542,11 @@ bool SrsHlsMuxer::is_segment_overflow() | ||
542 | { | 542 | { |
543 | srs_assert(current); | 543 | srs_assert(current); |
544 | 544 | ||
545 | + // to prevent very small segment. | ||
546 | + if (current->duration < 2 * SRS_AUTO_HLS_SEGMENT_MIN_DURATION_MS) { | ||
547 | + return false; | ||
548 | + } | ||
549 | + | ||
545 | // use N% deviation, to smoother. | 550 | // use N% deviation, to smoother. |
546 | double deviation = hls_ts_floor? SRS_HLS_FLOOR_REAP_PERCENT * deviation_ts * hls_fragment : 0.0; | 551 | double deviation = hls_ts_floor? SRS_HLS_FLOOR_REAP_PERCENT * deviation_ts * hls_fragment : 0.0; |
547 | srs_info("hls: dur=%.2f, tar=%.2f, dev=%.2fms/%dp, frag=%.2f", | 552 | srs_info("hls: dur=%.2f, tar=%.2f, dev=%.2fms/%dp, frag=%.2f", |
@@ -560,6 +565,11 @@ bool SrsHlsMuxer::is_segment_absolutely_overflow() | @@ -560,6 +565,11 @@ bool SrsHlsMuxer::is_segment_absolutely_overflow() | ||
560 | // @see https://github.com/winlinvip/simple-rtmp-server/issues/151#issuecomment-83553950 | 565 | // @see https://github.com/winlinvip/simple-rtmp-server/issues/151#issuecomment-83553950 |
561 | srs_assert(current); | 566 | srs_assert(current); |
562 | 567 | ||
568 | + // to prevent very small segment. | ||
569 | + if (current->duration < 2 * SRS_AUTO_HLS_SEGMENT_MIN_DURATION_MS) { | ||
570 | + return false; | ||
571 | + } | ||
572 | + | ||
563 | // use N% deviation, to smoother. | 573 | // use N% deviation, to smoother. |
564 | double deviation = hls_ts_floor? SRS_HLS_FLOOR_REAP_PERCENT * deviation_ts * hls_fragment : 0.0; | 574 | double deviation = hls_ts_floor? SRS_HLS_FLOOR_REAP_PERCENT * deviation_ts * hls_fragment : 0.0; |
565 | srs_info("hls: dur=%.2f, tar=%.2f, dev=%.2fms/%dp, frag=%.2f", | 575 | srs_info("hls: dur=%.2f, tar=%.2f, dev=%.2fms/%dp, frag=%.2f", |
@@ -871,9 +871,10 @@ int SrsIngestSrsOutput::parse_message_queue() | @@ -871,9 +871,10 @@ int SrsIngestSrsOutput::parse_message_queue() | ||
871 | 871 | ||
872 | SrsTsMessage* first_ts_msg = queue.begin()->second; | 872 | SrsTsMessage* first_ts_msg = queue.begin()->second; |
873 | SrsTsContext* context = first_ts_msg->channel->context; | 873 | SrsTsContext* context = first_ts_msg->channel->context; |
874 | + bool cpa = context->is_pure_audio(); | ||
874 | 875 | ||
875 | int nb_videos = 0; | 876 | int nb_videos = 0; |
876 | - if (!context->is_pure_audio()) { | 877 | + if (!cpa) { |
877 | std::multimap<int64_t, SrsTsMessage*>::iterator it; | 878 | std::multimap<int64_t, SrsTsMessage*>::iterator it; |
878 | for (it = queue.begin(); it != queue.end(); ++it) { | 879 | for (it = queue.begin(); it != queue.end(); ++it) { |
879 | SrsTsMessage* msg = it->second; | 880 | SrsTsMessage* msg = it->second; |
@@ -892,7 +893,8 @@ int SrsIngestSrsOutput::parse_message_queue() | @@ -892,7 +893,8 @@ int SrsIngestSrsOutput::parse_message_queue() | ||
892 | } | 893 | } |
893 | 894 | ||
894 | // parse messages util the last video. | 895 | // parse messages util the last video. |
895 | - while ((nb_videos > 1 || context->is_pure_audio()) && queue.size() > 0) { | 896 | + while ((cpa && queue.size() > 1) || nb_videos > 1) { |
897 | + srs_assert(!queue.empty()); | ||
896 | std::multimap<int64_t, SrsTsMessage*>::iterator it = queue.begin(); | 898 | std::multimap<int64_t, SrsTsMessage*>::iterator it = queue.begin(); |
897 | 899 | ||
898 | SrsTsMessage* msg = it->second; | 900 | SrsTsMessage* msg = it->second; |
-
请 注册 或 登录 后发表评论