-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ngx-live: fix audio ends before video issue (#208)
* ngx-live: fix audio ends before video issue the segmenter may try to cut a segment at the audio end timestamp, there is no video key frame at this timestamp - the video segments come out empty, and some of the audio frames are discarded. then it tries to create another segment, but the segments of all tracks come out empty, and the channel is failed. the fix is to avoid averaging the min/max split pts when the span is too large. in this case, the target pts will be the audio end pts, the video segments will come out empty, and the trailing audio will be discarded. * update readme * update UT
- Loading branch information
Showing
14 changed files
with
311 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
from test_base import * | ||
|
||
# EXPECTED: | ||
# 16 sec first video + audio | ||
# 2 sec first video, no audio | ||
# 10 sec second video + audio | ||
|
||
def test(channelId=CHANNEL_ID): | ||
st = KmpSendTimestamps() | ||
|
||
nl = setupChannelTimeline(channelId) | ||
|
||
rv = KmpMediaFileReader(TEST_VIDEO_HIGH, 0) | ||
ra = KmpMediaFileReader(TEST_VIDEO_HIGH, 1) | ||
|
||
sv, sa = createVariant(nl, VARIANT_ID, [('v1', 'video'), ('a1', 'audio')]) | ||
|
||
kmpSendStreams([ | ||
(rv, sv), | ||
(ra, sa), | ||
], st, 17.5, realtime=5) | ||
|
||
kmpSendStreams([ | ||
(rv, sv), | ||
(ra, KmpNullSender()), | ||
], st, 2, realtime=5) | ||
|
||
kmpSendEndOfStream([sv, sa]) | ||
|
||
time.sleep(2) | ||
|
||
initialFrameId = 1000000 | ||
|
||
rv = KmpMediaFileReader(TEST_VIDEO1, 0) | ||
ra = KmpMediaFileReader(TEST_VIDEO1, 1) | ||
|
||
sv, sa = createVariant(nl, VARIANT_ID, [('v1', 'video'), ('a1', 'audio')], initialFrameId=initialFrameId) | ||
|
||
kmpSendStreams([ | ||
(rv, sv), | ||
(ra, sa), | ||
], st, 10, realtime=5) | ||
|
||
kmpSendEndOfStream([sv, sa]) | ||
|
||
# deactivate the timeline | ||
nl.timeline.update(NginxLiveTimeline(id=TIMELINE_ID, end_list='on')) | ||
|
||
testDefaultStreams(channelId, __file__) |
75 changes: 75 additions & 0 deletions
75
nginx-live-module/test/tests/ref/audio_ends_before_video-hls-fmp4.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
URL: /master.m3u8 | ||
HEADERS: 200 application/vnd.apple.mpegurl | ||
BODY: #EXTM3U | ||
#EXT-X-INDEPENDENT-SEGMENTS | ||
|
||
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=126573,AVERAGE-BANDWIDTH=114074,RESOLUTION=160x120,FRAME-RATE=15.000,CODECS="avc1.64000b,mp4a.40.2" | ||
index-svar1.m3u8 | ||
|
||
URL: /index-svar1.m3u8 | ||
HEADERS: 200 application/vnd.apple.mpegurl | ||
BODY: #EXTM3U | ||
#EXT-X-TARGETDURATION:8 | ||
#EXT-X-VERSION:6 | ||
#EXT-X-MEDIA-SEQUENCE:0 | ||
#EXT-X-DISCONTINUITY-SEQUENCE:0 | ||
#EXT-X-INDEPENDENT-SEGMENTS | ||
#EXT-X-ALLOW-CACHE:YES | ||
#EXT-X-MAP:URI="init-1-svar1.mp4" | ||
#EXT-X-PROGRAM-DATE-TIME:2020-01-01T00:00:00.000+00:00 | ||
#EXTINF:8.342, | ||
#EXT-X-BITRATE:4971 | ||
seg-1-svar1.m4s | ||
#EXTINF:7.966, | ||
#EXT-X-BITRATE:16215 | ||
seg-2-svar1.m4s | ||
#EXT-X-DISCONTINUITY | ||
#EXT-X-PROGRAM-DATE-TIME:2020-01-01T00:00:16.342+00:00 | ||
#EXTINF:3.200, | ||
#EXT-X-BITRATE:9141 | ||
seg-3-svar1.m4s | ||
#EXT-X-DISCONTINUITY | ||
#EXT-X-MAP:URI="init-5-svar1.mp4" | ||
#EXT-X-PROGRAM-DATE-TIME:2020-01-01T00:00:19.630+00:00 | ||
#EXTINF:3.956, | ||
#EXT-X-BITRATE:92 | ||
seg-5-svar1.m4s | ||
#EXTINF:3.934, | ||
#EXT-X-BITRATE:123 | ||
seg-6-svar1.m4s | ||
#EXTINF:1.989, | ||
#EXT-X-BITRATE:124 | ||
seg-7-svar1.m4s | ||
#EXT-X-ENDLIST | ||
|
||
URL: /init-1-svar1.mp4 | ||
HEADERS: 200 video/mp4 | ||
BODY: SIZE: 1106, MD5: 44623fdc2bb6eb1183e22c022be3e765 | ||
|
||
URL: /seg-1-svar1.m4s | ||
HEADERS: 200 video/mp4 | ||
BODY: SIZE: 5180236, MD5: 0d015341c4fbb773cfcc90ecbce81d0d | ||
|
||
URL: /seg-2-svar1.m4s | ||
HEADERS: 200 video/mp4 | ||
BODY: SIZE: 16014394, MD5: 309376ada6e59c0222bf0bab74028e1e | ||
|
||
URL: /seg-3-svar1.m4s | ||
HEADERS: 200 video/mp4 | ||
BODY: SIZE: 3732604, MD5: 12a71bf0970f3bafec0a7b800eb51b78 | ||
|
||
URL: /init-5-svar1.mp4 | ||
HEADERS: 200 video/mp4 | ||
BODY: SIZE: 1106, MD5: ca1c220b1d37d697270c21bce220cdef | ||
|
||
URL: /seg-5-svar1.m4s | ||
HEADERS: 200 video/mp4 | ||
BODY: SIZE: 46063, MD5: 3cd142c193f879afc375070a3e30d431 | ||
|
||
URL: /seg-6-svar1.m4s | ||
HEADERS: 200 video/mp4 | ||
BODY: SIZE: 61926, MD5: 8ab6413490c066bb6cbed25d13cdc626 | ||
|
||
URL: /seg-7-svar1.m4s | ||
HEADERS: 200 video/mp4 | ||
BODY: SIZE: 32681, MD5: c03e8d0a6bd6bbb23a5844be89e1b6ea |
65 changes: 65 additions & 0 deletions
65
nginx-live-module/test/tests/ref/audio_ends_before_video-hls-ts.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
URL: /master.m3u8 | ||
HEADERS: 200 application/vnd.apple.mpegurl | ||
BODY: #EXTM3U | ||
#EXT-X-INDEPENDENT-SEGMENTS | ||
|
||
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=144154,AVERAGE-BANDWIDTH=131383,RESOLUTION=160x120,FRAME-RATE=15.000,CODECS="avc1.64000b,mp4a.40.2" | ||
index-svar1.m3u8 | ||
|
||
URL: /index-svar1.m3u8 | ||
HEADERS: 200 application/vnd.apple.mpegurl | ||
BODY: #EXTM3U | ||
#EXT-X-TARGETDURATION:8 | ||
#EXT-X-VERSION:3 | ||
#EXT-X-MEDIA-SEQUENCE:0 | ||
#EXT-X-DISCONTINUITY-SEQUENCE:0 | ||
#EXT-X-INDEPENDENT-SEGMENTS | ||
#EXT-X-ALLOW-CACHE:YES | ||
#EXT-X-PROGRAM-DATE-TIME:2020-01-01T00:00:00.000+00:00 | ||
#EXTINF:8.342, | ||
#EXT-X-BITRATE:5124 | ||
seg-1-svar1.ts | ||
#EXTINF:7.966, | ||
#EXT-X-BITRATE:16612 | ||
seg-2-svar1.ts | ||
#EXT-X-DISCONTINUITY | ||
#EXT-X-PROGRAM-DATE-TIME:2020-01-01T00:00:16.342+00:00 | ||
#EXTINF:3.200, | ||
#EXT-X-BITRATE:9369 | ||
seg-3-svar1.ts | ||
#EXT-X-DISCONTINUITY | ||
#EXT-X-PROGRAM-DATE-TIME:2020-01-01T00:00:19.630+00:00 | ||
#EXTINF:3.956, | ||
#EXT-X-BITRATE:112 | ||
seg-5-svar1.ts | ||
#EXTINF:3.934, | ||
#EXT-X-BITRATE:145 | ||
seg-6-svar1.ts | ||
#EXTINF:1.989, | ||
#EXT-X-BITRATE:152 | ||
seg-7-svar1.ts | ||
#EXT-X-ENDLIST | ||
|
||
URL: /seg-1-svar1.ts | ||
HEADERS: 200 video/mp2t | ||
BODY: SIZE: 5348788, MD5: f120a8a081f82c373c2699c75a46c728 | ||
|
||
URL: /seg-2-svar1.ts | ||
HEADERS: 200 video/mp2t | ||
BODY: SIZE: 16418228, MD5: 7bb081750052c1cb319753d8110c96f5 | ||
|
||
URL: /seg-3-svar1.ts | ||
HEADERS: 200 video/mp2t | ||
BODY: SIZE: 3826740, MD5: 61905a4e992990544087081a6855f90a | ||
|
||
URL: /seg-5-svar1.ts | ||
HEADERS: 200 video/mp2t | ||
BODY: SIZE: 57716, MD5: 9aba89a2ef46c155e15b0f587bad8a61 | ||
|
||
URL: /seg-6-svar1.ts | ||
HEADERS: 200 video/mp2t | ||
BODY: SIZE: 72756, MD5: 57df738394e340264cde12be20eaedfa | ||
|
||
URL: /seg-7-svar1.ts | ||
HEADERS: 200 video/mp2t | ||
BODY: SIZE: 39668, MD5: 4abc468def0cb3c8a592da711861fd1c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.