From 21174b2ee743c9ea1a0bccb46436c56c871febd3 Mon Sep 17 00:00:00 2001 From: Roman Arutyunyan Date: Tue, 16 Oct 2012 14:09:52 +0400 Subject: [PATCH] fixed pts assignment while synchronizing hls --- hls/ngx_rtmp_hls_module.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hls/ngx_rtmp_hls_module.c b/hls/ngx_rtmp_hls_module.c index 5073800..6ac2c4b 100644 --- a/hls/ngx_rtmp_hls_module.c +++ b/hls/ngx_rtmp_hls_module.c @@ -947,7 +947,6 @@ ngx_rtmp_hls_audio(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h, /* write to file */ av_init_packet(&packet); packet.dts = h->timestamp * 90L; - packet.pts = packet.dts; packet.stream_index = ctx->out_astream; packet.data = buffer; packet.size = ngx_rtmp_hls_chain2buffer(buffer, sizeof(buffer), in, 1); @@ -961,6 +960,10 @@ ngx_rtmp_hls_audio(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h, codec_ctx->sample_rate; ddts = dts - packet.dts; + ngx_log_debug2(NGX_LOG_DEBUG_RTMP, s->connection->log, 0, + "hls: sync stat ddts=%L (%.5fs)", + ddts, ddts / 90000.); + if (ddts > (int64_t) hacf->sync * 90 || ddts < (int64_t) hacf->sync * -90) { @@ -977,6 +980,8 @@ ngx_rtmp_hls_audio(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h, ctx->aframe_num++; } + packet.pts = packet.dts; + if (codec_ctx->audio_codec_id == NGX_RTMP_AUDIO_AAC) { if (packet.size == 0) { ngx_log_error(NGX_LOG_ERR, s->connection->log, 0, @@ -1160,7 +1165,7 @@ ngx_rtmp_hls_create_app_conf(ngx_conf_t *cf) conf->playlen = NGX_CONF_UNSET; conf->nbuckets = 1024; - return conf; + return conf; }