From 0d1d7138e570bb314da972a4a716f2ed05875c36 Mon Sep 17 00:00:00 2001 From: anba8005 Date: Fri, 20 Jul 2012 22:44:44 +0300 Subject: [PATCH 1/2] HLS B-Frames fixed --- hls/ngx_rtmp_hls_module.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hls/ngx_rtmp_hls_module.c b/hls/ngx_rtmp_hls_module.c index 86dee4f..b4aa9c8 100644 --- a/hls/ngx_rtmp_hls_module.c +++ b/hls/ngx_rtmp_hls_module.c @@ -913,6 +913,7 @@ ngx_rtmp_hls_video(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h, uint32_t len, rlen; ngx_buf_t out; static u_char buffer[NGX_RTMP_HLS_BUFSIZE]; + int32_t cts; hacf = ngx_rtmp_get_module_app_conf(s, ngx_rtmp_hls_module); ctx = ngx_rtmp_get_module_ctx(s, ngx_rtmp_hls_module); @@ -948,9 +949,10 @@ ngx_rtmp_hls_video(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h, } /* 3 bytes: decoder delay */ - if (ngx_rtmp_hls_copy(s, NULL, &p, 3, &in) != NGX_OK) { + if (ngx_rtmp_hls_copy(s, &cts, &p, 3, &in) != NGX_OK) { return NGX_ERROR; } + cts = ((cts & 0x00FF0000) >> 16) | ((cts & 0x000000FF) << 16) | (cts & 0x0000FF00); out.pos = buffer; out.last = buffer + sizeof(buffer) - FF_INPUT_BUFFER_PADDING_SIZE; @@ -1023,7 +1025,7 @@ ngx_rtmp_hls_video(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h, av_init_packet(&packet); packet.dts = h->timestamp * 90; - packet.pts = packet.dts; + packet.pts = packet.dts + cts * 90; packet.stream_index = ctx->out_vstream; /* if (ftype == 1) { From e0f9d944a09f720f7645372a42d59b58eaed0544 Mon Sep 17 00:00:00 2001 From: anba8005 Date: Sun, 22 Jul 2012 13:41:35 +0300 Subject: [PATCH 2/2] dts overflow fixed --- hls/ngx_rtmp_hls_module.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hls/ngx_rtmp_hls_module.c b/hls/ngx_rtmp_hls_module.c index b4aa9c8..3c9a22d 100644 --- a/hls/ngx_rtmp_hls_module.c +++ b/hls/ngx_rtmp_hls_module.c @@ -873,7 +873,7 @@ 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 * 90; + packet.dts = h->timestamp * 90L; packet.pts = packet.dts; packet.stream_index = ctx->out_astream; packet.data = buffer; @@ -1024,7 +1024,7 @@ ngx_rtmp_hls_video(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h, } av_init_packet(&packet); - packet.dts = h->timestamp * 90; + packet.dts = h->timestamp * 90L; packet.pts = packet.dts + cts * 90; packet.stream_index = ctx->out_vstream; /*