Skip to content

Commit 43f1e42

Browse files
committed
Set DASH fragment max duration and fixed manifest.
1 parent e636a04 commit 43f1e42

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

dash/ngx_rtmp_dash_module.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,6 @@ ngx_rtmp_dash_write_playlist(ngx_rtmp_session_t *s)
252252
return NGX_ERROR;
253253
}
254254

255-
256255
#define NGX_RTMP_DASH_MANIFEST_HEADER \
257256
"<?xml version=\"1.0\"?>\n" \
258257
"<MPD\n" \
@@ -357,8 +356,13 @@ ngx_rtmp_dash_write_playlist(ngx_rtmp_session_t *s)
357356
start_time,
358357
pub_time,
359358
(ngx_uint_t) (dacf->fraglen / 1000),
360-
(ngx_uint_t) (dacf->fraglen / 500),
361-
(ngx_uint_t) (dacf->playlen / 1000));
359+
(ngx_uint_t) (dacf->fraglen / 1000),
360+
(ngx_uint_t) (dacf->fraglen / 250 + 1));
361+
362+
/*
363+
* timeShiftBufferDepth formula:
364+
* 2 * minBufferTime + max_fragment_length + 1
365+
*/
362366

363367
n = ngx_write_fd(fd, buffer, p - buffer);
364368

@@ -994,6 +998,11 @@ ngx_rtmp_dash_update_fragments(ngx_rtmp_session_t *s, ngx_int_t boundary,
994998
f->duration = timestamp - f->timestamp;
995999
hit = (f->duration >= dacf->fraglen);
9961000

1001+
/* keep fragment lengths within 2x factor for dash.js */
1002+
if (f->duration >= dacf->fraglen * 2) {
1003+
boundary = 1;
1004+
}
1005+
9971006
} else {
9981007

9991008
/* sometimes clients generate slightly unordered frames */

0 commit comments

Comments
 (0)