From 54bf394c0323ef43a33351852cebc430ce1e0974 Mon Sep 17 00:00:00 2001 From: koln67 <67125539+koln67@users.noreply.github.com> Date: Fri, 21 Aug 2020 19:04:24 +0000 Subject: [PATCH] [HLS] Ensure playlists with TS streams include FRAME-RATE It fixes the FRAME-RATE missing issue in #816. --- packager/app/test/testdata/avc-aac-ts/output.m3u8 | 2 +- packager/app/test/testdata/avc-aac-ts/output.mpd | 4 ++-- .../app/test/testdata/avc-ac3-ts-with-encryption/output.m3u8 | 2 +- packager/app/test/testdata/avc-ac3-ts/output.m3u8 | 2 +- .../avc-ts-aac-packed-audio-with-encryption/output.m3u8 | 2 +- .../avc-ts-ac3-packed-audio-with-encryption/output.m3u8 | 2 +- packager/app/test/testdata/avc-ts-event-playlist/output.m3u8 | 2 +- .../avc-ts-live-playlist-with-key-rotation/output.m3u8 | 2 +- packager/app/test/testdata/avc-ts-live-playlist/output.m3u8 | 2 +- .../testdata/avc-ts-with-encryption-and-fairplay/output.m3u8 | 2 +- .../output.m3u8 | 2 +- .../app/test/testdata/avc-ts-with-encryption/output.m3u8 | 2 +- .../app/test/testdata/ec3-packed-audio-encrypted/output.m3u8 | 2 +- packager/app/test/testdata/hls-segmented-webvtt/output.m3u8 | 2 +- packager/media/formats/mp2t/ts_muxer.cc | 5 +++++ packager/media/formats/mp2t/ts_muxer.h | 1 + 16 files changed, 21 insertions(+), 15 deletions(-) diff --git a/packager/app/test/testdata/avc-aac-ts/output.m3u8 b/packager/app/test/testdata/avc-aac-ts/output.m3u8 index ae7f43acf1..56e2ed8e0c 100644 --- a/packager/app/test/testdata/avc-aac-ts/output.m3u8 +++ b/packager/app/test/testdata/avc-aac-ts/output.m3u8 @@ -5,7 +5,7 @@ #EXT-X-MEDIA:TYPE=AUDIO,URI="bear-640x360-audio.m3u8",GROUP-ID="default-audio-group",NAME="stream_0",AUTOSELECT=YES,CHANNELS="2" -#EXT-X-STREAM-INF:BANDWIDTH=1217520,AVERAGE-BANDWIDTH=1117320,CODECS="avc1.64001e,mp4a.40.2",RESOLUTION=640x360,AUDIO="default-audio-group" +#EXT-X-STREAM-INF:BANDWIDTH=1217520,AVERAGE-BANDWIDTH=1117320,CODECS="avc1.64001e,mp4a.40.2",RESOLUTION=640x360,FRAME-RATE=29.970,AUDIO="default-audio-group" bear-640x360-video.m3u8 #EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=217180,AVERAGE-BANDWIDTH=157213,CODECS="avc1.64001e",RESOLUTION=640x360,URI="bear-640x360-video-iframe.m3u8" diff --git a/packager/app/test/testdata/avc-aac-ts/output.mpd b/packager/app/test/testdata/avc-aac-ts/output.mpd index e3f9a69f49..be4aca3840 100644 --- a/packager/app/test/testdata/avc-aac-ts/output.mpd +++ b/packager/app/test/testdata/avc-aac-ts/output.mpd @@ -2,8 +2,8 @@ - - + + diff --git a/packager/app/test/testdata/avc-ac3-ts-with-encryption/output.m3u8 b/packager/app/test/testdata/avc-ac3-ts-with-encryption/output.m3u8 index 097f2676d9..ac624cbc67 100644 --- a/packager/app/test/testdata/avc-ac3-ts-with-encryption/output.m3u8 +++ b/packager/app/test/testdata/avc-ac3-ts-with-encryption/output.m3u8 @@ -5,7 +5,7 @@ #EXT-X-MEDIA:TYPE=AUDIO,URI="bear-640x360-ac3-audio.m3u8",GROUP-ID="default-audio-group",NAME="stream_0",AUTOSELECT=YES,CHANNELS="2" -#EXT-X-STREAM-INF:BANDWIDTH=1242863,AVERAGE-BANDWIDTH=1148679,CODECS="avc1.64001e,ac-3",RESOLUTION=640x360,AUDIO="default-audio-group" +#EXT-X-STREAM-INF:BANDWIDTH=1242863,AVERAGE-BANDWIDTH=1148679,CODECS="avc1.64001e,ac-3",RESOLUTION=640x360,FRAME-RATE=29.970,AUDIO="default-audio-group" bear-640x360-ac3-video.m3u8 #EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=217180,AVERAGE-BANDWIDTH=157213,CODECS="avc1.64001e",RESOLUTION=640x360,URI="bear-640x360-ac3-video-iframe.m3u8" diff --git a/packager/app/test/testdata/avc-ac3-ts/output.m3u8 b/packager/app/test/testdata/avc-ac3-ts/output.m3u8 index 097f2676d9..ac624cbc67 100644 --- a/packager/app/test/testdata/avc-ac3-ts/output.m3u8 +++ b/packager/app/test/testdata/avc-ac3-ts/output.m3u8 @@ -5,7 +5,7 @@ #EXT-X-MEDIA:TYPE=AUDIO,URI="bear-640x360-ac3-audio.m3u8",GROUP-ID="default-audio-group",NAME="stream_0",AUTOSELECT=YES,CHANNELS="2" -#EXT-X-STREAM-INF:BANDWIDTH=1242863,AVERAGE-BANDWIDTH=1148679,CODECS="avc1.64001e,ac-3",RESOLUTION=640x360,AUDIO="default-audio-group" +#EXT-X-STREAM-INF:BANDWIDTH=1242863,AVERAGE-BANDWIDTH=1148679,CODECS="avc1.64001e,ac-3",RESOLUTION=640x360,FRAME-RATE=29.970,AUDIO="default-audio-group" bear-640x360-ac3-video.m3u8 #EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=217180,AVERAGE-BANDWIDTH=157213,CODECS="avc1.64001e",RESOLUTION=640x360,URI="bear-640x360-ac3-video-iframe.m3u8" diff --git a/packager/app/test/testdata/avc-ts-aac-packed-audio-with-encryption/output.m3u8 b/packager/app/test/testdata/avc-ts-aac-packed-audio-with-encryption/output.m3u8 index 2b0ca67220..73e7756ed1 100644 --- a/packager/app/test/testdata/avc-ts-aac-packed-audio-with-encryption/output.m3u8 +++ b/packager/app/test/testdata/avc-ts-aac-packed-audio-with-encryption/output.m3u8 @@ -5,7 +5,7 @@ #EXT-X-MEDIA:TYPE=AUDIO,URI="bear-640x360-audio.m3u8",GROUP-ID="default-audio-group",NAME="stream_0",AUTOSELECT=YES,CHANNELS="2" -#EXT-X-STREAM-INF:BANDWIDTH=1154999,AVERAGE-BANDWIDTH=1054750,CODECS="avc1.64001e,mp4a.40.2",RESOLUTION=640x360,AUDIO="default-audio-group" +#EXT-X-STREAM-INF:BANDWIDTH=1154999,AVERAGE-BANDWIDTH=1054750,CODECS="avc1.64001e,mp4a.40.2",RESOLUTION=640x360,FRAME-RATE=29.970,AUDIO="default-audio-group" bear-640x360-video.m3u8 #EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=217180,AVERAGE-BANDWIDTH=157213,CODECS="avc1.64001e",RESOLUTION=640x360,URI="bear-640x360-video-iframe.m3u8" diff --git a/packager/app/test/testdata/avc-ts-ac3-packed-audio-with-encryption/output.m3u8 b/packager/app/test/testdata/avc-ts-ac3-packed-audio-with-encryption/output.m3u8 index e77a2f0b5c..f6e812b786 100644 --- a/packager/app/test/testdata/avc-ts-ac3-packed-audio-with-encryption/output.m3u8 +++ b/packager/app/test/testdata/avc-ts-ac3-packed-audio-with-encryption/output.m3u8 @@ -5,7 +5,7 @@ #EXT-X-MEDIA:TYPE=AUDIO,URI="bear-640x360-ac3-audio.m3u8",GROUP-ID="default-audio-group",NAME="stream_0",AUTOSELECT=YES,CHANNELS="2" -#EXT-X-STREAM-INF:BANDWIDTH=1216578,AVERAGE-BANDWIDTH=1122532,CODECS="avc1.64001e,ac-3",RESOLUTION=640x360,AUDIO="default-audio-group" +#EXT-X-STREAM-INF:BANDWIDTH=1216578,AVERAGE-BANDWIDTH=1122532,CODECS="avc1.64001e,ac-3",RESOLUTION=640x360,FRAME-RATE=29.970,AUDIO="default-audio-group" bear-640x360-ac3-video.m3u8 #EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=217180,AVERAGE-BANDWIDTH=157213,CODECS="avc1.64001e",RESOLUTION=640x360,URI="bear-640x360-ac3-video-iframe.m3u8" diff --git a/packager/app/test/testdata/avc-ts-event-playlist/output.m3u8 b/packager/app/test/testdata/avc-ts-event-playlist/output.m3u8 index ae7f43acf1..56e2ed8e0c 100644 --- a/packager/app/test/testdata/avc-ts-event-playlist/output.m3u8 +++ b/packager/app/test/testdata/avc-ts-event-playlist/output.m3u8 @@ -5,7 +5,7 @@ #EXT-X-MEDIA:TYPE=AUDIO,URI="bear-640x360-audio.m3u8",GROUP-ID="default-audio-group",NAME="stream_0",AUTOSELECT=YES,CHANNELS="2" -#EXT-X-STREAM-INF:BANDWIDTH=1217520,AVERAGE-BANDWIDTH=1117320,CODECS="avc1.64001e,mp4a.40.2",RESOLUTION=640x360,AUDIO="default-audio-group" +#EXT-X-STREAM-INF:BANDWIDTH=1217520,AVERAGE-BANDWIDTH=1117320,CODECS="avc1.64001e,mp4a.40.2",RESOLUTION=640x360,FRAME-RATE=29.970,AUDIO="default-audio-group" bear-640x360-video.m3u8 #EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=217180,AVERAGE-BANDWIDTH=157213,CODECS="avc1.64001e",RESOLUTION=640x360,URI="bear-640x360-video-iframe.m3u8" diff --git a/packager/app/test/testdata/avc-ts-live-playlist-with-key-rotation/output.m3u8 b/packager/app/test/testdata/avc-ts-live-playlist-with-key-rotation/output.m3u8 index ae7f43acf1..56e2ed8e0c 100644 --- a/packager/app/test/testdata/avc-ts-live-playlist-with-key-rotation/output.m3u8 +++ b/packager/app/test/testdata/avc-ts-live-playlist-with-key-rotation/output.m3u8 @@ -5,7 +5,7 @@ #EXT-X-MEDIA:TYPE=AUDIO,URI="bear-640x360-audio.m3u8",GROUP-ID="default-audio-group",NAME="stream_0",AUTOSELECT=YES,CHANNELS="2" -#EXT-X-STREAM-INF:BANDWIDTH=1217520,AVERAGE-BANDWIDTH=1117320,CODECS="avc1.64001e,mp4a.40.2",RESOLUTION=640x360,AUDIO="default-audio-group" +#EXT-X-STREAM-INF:BANDWIDTH=1217520,AVERAGE-BANDWIDTH=1117320,CODECS="avc1.64001e,mp4a.40.2",RESOLUTION=640x360,FRAME-RATE=29.970,AUDIO="default-audio-group" bear-640x360-video.m3u8 #EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=217180,AVERAGE-BANDWIDTH=157213,CODECS="avc1.64001e",RESOLUTION=640x360,URI="bear-640x360-video-iframe.m3u8" diff --git a/packager/app/test/testdata/avc-ts-live-playlist/output.m3u8 b/packager/app/test/testdata/avc-ts-live-playlist/output.m3u8 index ae7f43acf1..56e2ed8e0c 100644 --- a/packager/app/test/testdata/avc-ts-live-playlist/output.m3u8 +++ b/packager/app/test/testdata/avc-ts-live-playlist/output.m3u8 @@ -5,7 +5,7 @@ #EXT-X-MEDIA:TYPE=AUDIO,URI="bear-640x360-audio.m3u8",GROUP-ID="default-audio-group",NAME="stream_0",AUTOSELECT=YES,CHANNELS="2" -#EXT-X-STREAM-INF:BANDWIDTH=1217520,AVERAGE-BANDWIDTH=1117320,CODECS="avc1.64001e,mp4a.40.2",RESOLUTION=640x360,AUDIO="default-audio-group" +#EXT-X-STREAM-INF:BANDWIDTH=1217520,AVERAGE-BANDWIDTH=1117320,CODECS="avc1.64001e,mp4a.40.2",RESOLUTION=640x360,FRAME-RATE=29.970,AUDIO="default-audio-group" bear-640x360-video.m3u8 #EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=217180,AVERAGE-BANDWIDTH=157213,CODECS="avc1.64001e",RESOLUTION=640x360,URI="bear-640x360-video-iframe.m3u8" diff --git a/packager/app/test/testdata/avc-ts-with-encryption-and-fairplay/output.m3u8 b/packager/app/test/testdata/avc-ts-with-encryption-and-fairplay/output.m3u8 index ae7f43acf1..56e2ed8e0c 100644 --- a/packager/app/test/testdata/avc-ts-with-encryption-and-fairplay/output.m3u8 +++ b/packager/app/test/testdata/avc-ts-with-encryption-and-fairplay/output.m3u8 @@ -5,7 +5,7 @@ #EXT-X-MEDIA:TYPE=AUDIO,URI="bear-640x360-audio.m3u8",GROUP-ID="default-audio-group",NAME="stream_0",AUTOSELECT=YES,CHANNELS="2" -#EXT-X-STREAM-INF:BANDWIDTH=1217520,AVERAGE-BANDWIDTH=1117320,CODECS="avc1.64001e,mp4a.40.2",RESOLUTION=640x360,AUDIO="default-audio-group" +#EXT-X-STREAM-INF:BANDWIDTH=1217520,AVERAGE-BANDWIDTH=1117320,CODECS="avc1.64001e,mp4a.40.2",RESOLUTION=640x360,FRAME-RATE=29.970,AUDIO="default-audio-group" bear-640x360-video.m3u8 #EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=217180,AVERAGE-BANDWIDTH=157213,CODECS="avc1.64001e",RESOLUTION=640x360,URI="bear-640x360-video-iframe.m3u8" diff --git a/packager/app/test/testdata/avc-ts-with-encryption-exercise-emulation-prevention/output.m3u8 b/packager/app/test/testdata/avc-ts-with-encryption-exercise-emulation-prevention/output.m3u8 index 9c0f04387d..cb5602d944 100644 --- a/packager/app/test/testdata/avc-ts-with-encryption-exercise-emulation-prevention/output.m3u8 +++ b/packager/app/test/testdata/avc-ts-with-encryption-exercise-emulation-prevention/output.m3u8 @@ -3,7 +3,7 @@ #EXT-X-INDEPENDENT-SEGMENTS -#EXT-X-STREAM-INF:BANDWIDTH=863296,AVERAGE-BANDWIDTH=390288,CODECS="avc1.64001f",RESOLUTION=1024x436 +#EXT-X-STREAM-INF:BANDWIDTH=863296,AVERAGE-BANDWIDTH=390288,CODECS="avc1.64001f",RESOLUTION=1024x436,FRAME-RATE=24.000 sintel-1024x436-video.m3u8 #EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=88736,AVERAGE-BANDWIDTH=40358,CODECS="avc1.64001f",RESOLUTION=1024x436,URI="sintel-1024x436-video-iframe.m3u8" diff --git a/packager/app/test/testdata/avc-ts-with-encryption/output.m3u8 b/packager/app/test/testdata/avc-ts-with-encryption/output.m3u8 index ae7f43acf1..56e2ed8e0c 100644 --- a/packager/app/test/testdata/avc-ts-with-encryption/output.m3u8 +++ b/packager/app/test/testdata/avc-ts-with-encryption/output.m3u8 @@ -5,7 +5,7 @@ #EXT-X-MEDIA:TYPE=AUDIO,URI="bear-640x360-audio.m3u8",GROUP-ID="default-audio-group",NAME="stream_0",AUTOSELECT=YES,CHANNELS="2" -#EXT-X-STREAM-INF:BANDWIDTH=1217520,AVERAGE-BANDWIDTH=1117320,CODECS="avc1.64001e,mp4a.40.2",RESOLUTION=640x360,AUDIO="default-audio-group" +#EXT-X-STREAM-INF:BANDWIDTH=1217520,AVERAGE-BANDWIDTH=1117320,CODECS="avc1.64001e,mp4a.40.2",RESOLUTION=640x360,FRAME-RATE=29.970,AUDIO="default-audio-group" bear-640x360-video.m3u8 #EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=217180,AVERAGE-BANDWIDTH=157213,CODECS="avc1.64001e",RESOLUTION=640x360,URI="bear-640x360-video-iframe.m3u8" diff --git a/packager/app/test/testdata/ec3-packed-audio-encrypted/output.m3u8 b/packager/app/test/testdata/ec3-packed-audio-encrypted/output.m3u8 index b805513ab3..769aee0efb 100644 --- a/packager/app/test/testdata/ec3-packed-audio-encrypted/output.m3u8 +++ b/packager/app/test/testdata/ec3-packed-audio-encrypted/output.m3u8 @@ -5,7 +5,7 @@ #EXT-X-MEDIA:TYPE=AUDIO,URI="bear-640x360-ec3-audio.m3u8",GROUP-ID="default-audio-group",NAME="stream_0",AUTOSELECT=YES,CHANNELS="2" -#EXT-X-STREAM-INF:BANDWIDTH=1216655,AVERAGE-BANDWIDTH=1104925,CODECS="avc1.64001e,ec-3",RESOLUTION=640x360,AUDIO="default-audio-group" +#EXT-X-STREAM-INF:BANDWIDTH=1216655,AVERAGE-BANDWIDTH=1104925,CODECS="avc1.64001e,ec-3",RESOLUTION=640x360,FRAME-RATE=9.990,AUDIO="default-audio-group" bear-640x360-ec3-video.m3u8 #EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=217180,AVERAGE-BANDWIDTH=157213,CODECS="avc1.64001e",RESOLUTION=640x360,URI="bear-640x360-ec3-video-iframe.m3u8" diff --git a/packager/app/test/testdata/hls-segmented-webvtt/output.m3u8 b/packager/app/test/testdata/hls-segmented-webvtt/output.m3u8 index b73ecd3c65..8300ddf271 100644 --- a/packager/app/test/testdata/hls-segmented-webvtt/output.m3u8 +++ b/packager/app/test/testdata/hls-segmented-webvtt/output.m3u8 @@ -7,5 +7,5 @@ #EXT-X-MEDIA:TYPE=SUBTITLES,URI="stream_0.m3u8",GROUP-ID="default-text-group",NAME="stream_0",AUTOSELECT=YES,CHARACTERISTICS="public.accessibility.transcribes-spoken-dialog,private.accessibility.widevine-special" -#EXT-X-STREAM-INF:BANDWIDTH=1217518,AVERAGE-BANDWIDTH=1117319,CODECS="avc1.64001e,mp4a.40.2",RESOLUTION=640x360,AUDIO="default-audio-group",SUBTITLES="default-text-group" +#EXT-X-STREAM-INF:BANDWIDTH=1217518,AVERAGE-BANDWIDTH=1117319,CODECS="avc1.64001e,mp4a.40.2",RESOLUTION=640x360,FRAME-RATE=29.970,AUDIO="default-audio-group",SUBTITLES="default-text-group" stream_2.m3u8 diff --git a/packager/media/formats/mp2t/ts_muxer.cc b/packager/media/formats/mp2t/ts_muxer.cc index bd005afa04..4c5bab7e78 100644 --- a/packager/media/formats/mp2t/ts_muxer.cc +++ b/packager/media/formats/mp2t/ts_muxer.cc @@ -34,6 +34,11 @@ Status TsMuxer::Finalize() { Status TsMuxer::AddSample(size_t stream_id, const MediaSample& sample) { DCHECK_EQ(stream_id, 0u); + if (sample_duration_ == 0) { + sample_duration_ = sample.duration() * kTsTimescale / streams().front()->time_scale(); + if (muxer_listener()) + muxer_listener()->OnSampleDurationReady(sample_duration_); + } return segmenter_->AddSample(sample); } diff --git a/packager/media/formats/mp2t/ts_muxer.h b/packager/media/formats/mp2t/ts_muxer.h index e0129dff65..c2aab357cd 100644 --- a/packager/media/formats/mp2t/ts_muxer.h +++ b/packager/media/formats/mp2t/ts_muxer.h @@ -35,6 +35,7 @@ class TsMuxer : public Muxer { void FireOnMediaEndEvent(); std::unique_ptr segmenter_; + int64_t sample_duration_ = 0; DISALLOW_COPY_AND_ASSIGN(TsMuxer); };