diff --git a/trunk/conf/full.conf b/trunk/conf/full.conf index 72d1153c3..f0f3ca74c 100644 --- a/trunk/conf/full.conf +++ b/trunk/conf/full.conf @@ -928,12 +928,12 @@ vhost with-hls.srs.com { # default: 60 hls_window 60; # the error strategy. canbe: - # ignore, when error ignore and disable hls. - # disconnect, when error disconnect the publish connection. - # continue, when error ignore and continue output hls. + # ignore, disable the hls. + # disconnect, require encoder republish. + # continue, ignore failed try to continue output hls. # @see https://github.com/ossrs/srs/issues/264 - # default: ignore - hls_on_error ignore; + # default: continue + hls_on_error continue; # the hls storage: disk, ram or both. # disk, to write hls m3u8/ts to disk. # ram, serve m3u8/ts in memory, which use embeded http server to delivery. diff --git a/trunk/src/app/srs_app_config.cpp b/trunk/src/app/srs_app_config.cpp index 899c86b5f..011344f46 100644 --- a/trunk/src/app/srs_app_config.cpp +++ b/trunk/src/app/srs_app_config.cpp @@ -6002,7 +6002,8 @@ double SrsConfig::get_hls_window(string vhost) string SrsConfig::get_hls_on_error(string vhost) { - static string DEFAULT = "ignore"; + // try to ignore the error. + static string DEFAULT = "continue"; SrsConfDirective* conf = get_hls(vhost); if (!conf) { diff --git a/trunk/src/app/srs_app_source.cpp b/trunk/src/app/srs_app_source.cpp index 02935089b..a3cb61601 100644 --- a/trunk/src/app/srs_app_source.cpp +++ b/trunk/src/app/srs_app_source.cpp @@ -1770,6 +1770,23 @@ int SrsSource::on_video(SrsCommonMessage* shared_video) return ret; } +bool srs_hls_can_continue(int ret, SrsSharedPtrMessage* sh, SrsSharedPtrMessage* video) +{ + // only continue for decode error. + if (ret != ERROR_HLS_DECODE_ERROR) { + return false; + } + + // when video size equals to sequence header, + // the video actually maybe a sequence header, + // continue to make ffmpeg happy. + if (sh && sh->size == video->size) { + return true; + } + + return false; +} + int SrsSource::on_video_imp(SrsSharedPtrMessage* msg) { int ret = ERROR_SUCCESS; @@ -1834,7 +1851,7 @@ int SrsSource::on_video_imp(SrsSharedPtrMessage* msg) ret = ERROR_SUCCESS; } else if (srs_config_hls_is_on_error_continue(hls_error_strategy)) { // compare the sequence header with video, continue when it's actually an sequence header. - if (ret == ERROR_HLS_DECODE_ERROR && cache_sh_video && cache_sh_video->size == msg->size) { + if (srs_hls_can_continue(ret, cache_sh_video, msg)) { srs_warn("the video is actually a sequence header, ignore this packet."); ret = ERROR_SUCCESS; } else {