mirror of
https://github.com/arut/nginx-rtmp-module.git
synced 2025-08-14 00:56:16 +08:00
fixed pts assignment while synchronizing hls
This commit is contained in:
@ -947,7 +947,6 @@ ngx_rtmp_hls_audio(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,
|
|||||||
/* write to file */
|
/* write to file */
|
||||||
av_init_packet(&packet);
|
av_init_packet(&packet);
|
||||||
packet.dts = h->timestamp * 90L;
|
packet.dts = h->timestamp * 90L;
|
||||||
packet.pts = packet.dts;
|
|
||||||
packet.stream_index = ctx->out_astream;
|
packet.stream_index = ctx->out_astream;
|
||||||
packet.data = buffer;
|
packet.data = buffer;
|
||||||
packet.size = ngx_rtmp_hls_chain2buffer(buffer, sizeof(buffer), in, 1);
|
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;
|
codec_ctx->sample_rate;
|
||||||
ddts = dts - packet.dts;
|
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 ||
|
if (ddts > (int64_t) hacf->sync * 90 ||
|
||||||
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++;
|
ctx->aframe_num++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
packet.pts = packet.dts;
|
||||||
|
|
||||||
if (codec_ctx->audio_codec_id == NGX_RTMP_AUDIO_AAC) {
|
if (codec_ctx->audio_codec_id == NGX_RTMP_AUDIO_AAC) {
|
||||||
if (packet.size == 0) {
|
if (packet.size == 0) {
|
||||||
ngx_log_error(NGX_LOG_ERR, s->connection->log, 0,
|
ngx_log_error(NGX_LOG_ERR, s->connection->log, 0,
|
||||||
|
Reference in New Issue
Block a user