fixed pts assignment while synchronizing hls

This commit is contained in:
Roman Arutyunyan
2012-10-16 14:09:52 +04:00
parent 5aac8b5cb3
commit 21174b2ee7

View File

@ -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;
}