diff --git a/docs/source/tutorials/dash_hls_example.rst b/docs/source/tutorials/dash_hls_example.rst index 8d422d2cc2..dcd6e95151 100644 --- a/docs/source/tutorials/dash_hls_example.rst +++ b/docs/source/tutorials/dash_hls_example.rst @@ -16,8 +16,8 @@ playlists as well as DASH manifests. $ packager \ 'in=h264_baseline_360p_600.mp4,stream=audio,init_segment=audio/init.mp4,segment_template=audio/$Number$.m4s' \ - 'in=input_text.vtt,stream=text,init_segment=text/init.mp4,segment_template=text/$Number$.m4s,dash_only=true' \ - 'in=input_text.vtt,stream=text,segment_template=text/$Number$.vtt,hls_only=true' \ + 'in=input_text.vtt,stream=text,init_segment=text/init.mp4,segment_template=text/$Number$.m4s,dash_only=1' \ + 'in=input_text.vtt,stream=text,segment_template=text/$Number$.vtt,hls_only=1' \ 'in=h264_baseline_360p_600.mp4,stream=video,init_segment=h264_360p/init.mp4,segment_template=h264_360p/$Number$.m4s' \ 'in=h264_main_480p_1000.mp4,stream=video,init_segment=h264_480p/init.mp4,segment_template=h264_480p/$Number$.m4s' \ 'in=h264_main_720p_3000.mp4,stream=video,init_segment=h264_720p/init.mp4,segment_template=h264_720p/$Number$.m4s' \ diff --git a/packager/app/test/packager_test.py b/packager/app/test/packager_test.py index 6d5a255687..188465e798 100755 --- a/packager/app/test/packager_test.py +++ b/packager/app/test/packager_test.py @@ -719,6 +719,29 @@ class PackagerFunctionalTest(PackagerAppTest): # order of trick play factors gets the same mpd. self._CheckTestResults('audio-video-with-two-trick-play') + def testDashOnlyAndHlsOnlyWithCaptions(self): + audio_video_streams = self._GetStreams(['audio', 'video'], segmented=True) + dash_text_stream = self._GetStreams(['text'], + test_files=['bear-english.vtt'], + output_format='mp4', + segmented=True, + dash_only=True) + hls_text_stream = self._GetStreams(['text'], + test_files=['bear-english.vtt'], + segmented=True, + hls_only=True) + streams = audio_video_streams + dash_text_stream + hls_text_stream + self.assertPackageSuccess(streams, self._GetFlags(output_dash=True, + output_hls=True)) + # Mpd cannot be validated right now since we don't generate deterministic + # mpd with multiple inputs due to thread racing. + # TODO(b/73349711): Generate deterministic mpd or at least validate mpd + # schema. + self._CheckTestResults( + 'hls-only-dash-only-captions', + diff_files_policy=DiffFilesPolicy( + allowed_diff_files=['output.mpd'], exact=False)) + def testDashOnlyAndHlsOnly(self): streams = [ self._GetStream('video', hls_only=True), diff --git a/packager/app/test/testdata/hls-only-dash-only-captions/bear-640x360-audio-1.m4s b/packager/app/test/testdata/hls-only-dash-only-captions/bear-640x360-audio-1.m4s new file mode 100644 index 0000000000..55ee417db1 Binary files /dev/null and b/packager/app/test/testdata/hls-only-dash-only-captions/bear-640x360-audio-1.m4s differ diff --git a/packager/app/test/testdata/hls-only-dash-only-captions/bear-640x360-audio-2.m4s b/packager/app/test/testdata/hls-only-dash-only-captions/bear-640x360-audio-2.m4s new file mode 100644 index 0000000000..1ddbee3bdd Binary files /dev/null and b/packager/app/test/testdata/hls-only-dash-only-captions/bear-640x360-audio-2.m4s differ diff --git a/packager/app/test/testdata/hls-only-dash-only-captions/bear-640x360-audio-3.m4s b/packager/app/test/testdata/hls-only-dash-only-captions/bear-640x360-audio-3.m4s new file mode 100644 index 0000000000..a7100e5c24 Binary files /dev/null and b/packager/app/test/testdata/hls-only-dash-only-captions/bear-640x360-audio-3.m4s differ diff --git a/packager/app/test/testdata/hls-only-dash-only-captions/bear-640x360-audio-init.mp4 b/packager/app/test/testdata/hls-only-dash-only-captions/bear-640x360-audio-init.mp4 new file mode 100644 index 0000000000..1ba3d9abb9 Binary files /dev/null and b/packager/app/test/testdata/hls-only-dash-only-captions/bear-640x360-audio-init.mp4 differ diff --git a/packager/app/test/testdata/hls-only-dash-only-captions/bear-640x360-video-1.m4s b/packager/app/test/testdata/hls-only-dash-only-captions/bear-640x360-video-1.m4s new file mode 100644 index 0000000000..4dbca6653f Binary files /dev/null and b/packager/app/test/testdata/hls-only-dash-only-captions/bear-640x360-video-1.m4s differ diff --git a/packager/app/test/testdata/hls-only-dash-only-captions/bear-640x360-video-2.m4s b/packager/app/test/testdata/hls-only-dash-only-captions/bear-640x360-video-2.m4s new file mode 100644 index 0000000000..da2f00a606 Binary files /dev/null and b/packager/app/test/testdata/hls-only-dash-only-captions/bear-640x360-video-2.m4s differ diff --git a/packager/app/test/testdata/hls-only-dash-only-captions/bear-640x360-video-3.m4s b/packager/app/test/testdata/hls-only-dash-only-captions/bear-640x360-video-3.m4s new file mode 100644 index 0000000000..8dfe74ca5b Binary files /dev/null and b/packager/app/test/testdata/hls-only-dash-only-captions/bear-640x360-video-3.m4s differ diff --git a/packager/app/test/testdata/hls-only-dash-only-captions/bear-640x360-video-init.mp4 b/packager/app/test/testdata/hls-only-dash-only-captions/bear-640x360-video-init.mp4 new file mode 100644 index 0000000000..aa3f67b37c Binary files /dev/null and b/packager/app/test/testdata/hls-only-dash-only-captions/bear-640x360-video-init.mp4 differ diff --git a/packager/app/test/testdata/hls-only-dash-only-captions/bear-english-text-1.m4s b/packager/app/test/testdata/hls-only-dash-only-captions/bear-english-text-1.m4s new file mode 100644 index 0000000000..577826f3fa Binary files /dev/null and b/packager/app/test/testdata/hls-only-dash-only-captions/bear-english-text-1.m4s differ diff --git a/packager/app/test/testdata/hls-only-dash-only-captions/bear-english-text-1.vtt b/packager/app/test/testdata/hls-only-dash-only-captions/bear-english-text-1.vtt new file mode 100644 index 0000000000..cd7ad3d7bd --- /dev/null +++ b/packager/app/test/testdata/hls-only-dash-only-captions/bear-english-text-1.vtt @@ -0,0 +1,8 @@ +WEBVTT + +STYLE +::cue { color:lime } + +00:00:00.000 --> 00:00:00.800 +Yup, that's a bear, eh. + diff --git a/packager/app/test/testdata/hls-only-dash-only-captions/bear-english-text-2.m4s b/packager/app/test/testdata/hls-only-dash-only-captions/bear-english-text-2.m4s new file mode 100644 index 0000000000..806b3320da Binary files /dev/null and b/packager/app/test/testdata/hls-only-dash-only-captions/bear-english-text-2.m4s differ diff --git a/packager/app/test/testdata/hls-only-dash-only-captions/bear-english-text-2.vtt b/packager/app/test/testdata/hls-only-dash-only-captions/bear-english-text-2.vtt new file mode 100644 index 0000000000..ae16c7bd9a --- /dev/null +++ b/packager/app/test/testdata/hls-only-dash-only-captions/bear-english-text-2.vtt @@ -0,0 +1,8 @@ +WEBVTT + +STYLE +::cue { color:lime } + +00:00:01.000 --> 00:00:04.700 +He 's... um... doing bear-like stuff. + diff --git a/packager/app/test/testdata/hls-only-dash-only-captions/bear-english-text-3.m4s b/packager/app/test/testdata/hls-only-dash-only-captions/bear-english-text-3.m4s new file mode 100644 index 0000000000..22368c5f30 Binary files /dev/null and b/packager/app/test/testdata/hls-only-dash-only-captions/bear-english-text-3.m4s differ diff --git a/packager/app/test/testdata/hls-only-dash-only-captions/bear-english-text-3.vtt b/packager/app/test/testdata/hls-only-dash-only-captions/bear-english-text-3.vtt new file mode 100644 index 0000000000..ae16c7bd9a --- /dev/null +++ b/packager/app/test/testdata/hls-only-dash-only-captions/bear-english-text-3.vtt @@ -0,0 +1,8 @@ +WEBVTT + +STYLE +::cue { color:lime } + +00:00:01.000 --> 00:00:04.700 +He 's... um... doing bear-like stuff. + diff --git a/packager/app/test/testdata/hls-only-dash-only-captions/bear-english-text-4.m4s b/packager/app/test/testdata/hls-only-dash-only-captions/bear-english-text-4.m4s new file mode 100644 index 0000000000..a4abbbe1de Binary files /dev/null and b/packager/app/test/testdata/hls-only-dash-only-captions/bear-english-text-4.m4s differ diff --git a/packager/app/test/testdata/hls-only-dash-only-captions/bear-english-text-4.vtt b/packager/app/test/testdata/hls-only-dash-only-captions/bear-english-text-4.vtt new file mode 100644 index 0000000000..ae16c7bd9a --- /dev/null +++ b/packager/app/test/testdata/hls-only-dash-only-captions/bear-english-text-4.vtt @@ -0,0 +1,8 @@ +WEBVTT + +STYLE +::cue { color:lime } + +00:00:01.000 --> 00:00:04.700 +He 's... um... doing bear-like stuff. + diff --git a/packager/app/test/testdata/hls-only-dash-only-captions/bear-english-text-5.m4s b/packager/app/test/testdata/hls-only-dash-only-captions/bear-english-text-5.m4s new file mode 100644 index 0000000000..904dea7dbe Binary files /dev/null and b/packager/app/test/testdata/hls-only-dash-only-captions/bear-english-text-5.m4s differ diff --git a/packager/app/test/testdata/hls-only-dash-only-captions/bear-english-text-5.vtt b/packager/app/test/testdata/hls-only-dash-only-captions/bear-english-text-5.vtt new file mode 100644 index 0000000000..ae16c7bd9a --- /dev/null +++ b/packager/app/test/testdata/hls-only-dash-only-captions/bear-english-text-5.vtt @@ -0,0 +1,8 @@ +WEBVTT + +STYLE +::cue { color:lime } + +00:00:01.000 --> 00:00:04.700 +He 's... um... doing bear-like stuff. + diff --git a/packager/app/test/testdata/hls-only-dash-only-captions/bear-english-text-init.mp4 b/packager/app/test/testdata/hls-only-dash-only-captions/bear-english-text-init.mp4 new file mode 100644 index 0000000000..0ec4fa9c16 Binary files /dev/null and b/packager/app/test/testdata/hls-only-dash-only-captions/bear-english-text-init.mp4 differ diff --git a/packager/app/test/testdata/hls-only-dash-only-captions/output.m3u8 b/packager/app/test/testdata/hls-only-dash-only-captions/output.m3u8 new file mode 100644 index 0000000000..6c732455fd --- /dev/null +++ b/packager/app/test/testdata/hls-only-dash-only-captions/output.m3u8 @@ -0,0 +1,9 @@ +#EXTM3U +## Generated with https://github.com/google/shaka-packager version -- + +#EXT-X-MEDIA:TYPE=AUDIO,URI="stream_2.m3u8",GROUP-ID="default-audio-group",NAME="stream_2",AUTOSELECT=YES,CHANNELS="2" + +#EXT-X-MEDIA:TYPE=SUBTITLES,URI="stream_1.m3u8",GROUP-ID="default-text-group",NAME="stream_1",AUTOSELECT=YES + +#EXT-X-STREAM-INF:BANDWIDTH=1108051,AVERAGE-BANDWIDTH=1005999,CODECS="avc1.64001e,mp4a.40.2",RESOLUTION=640x360,FRAME-RATE=29.970,AUDIO="default-audio-group",SUBTITLES="default-text-group" +stream_3.m3u8 diff --git a/packager/app/test/testdata/hls-only-dash-only-captions/output.mpd b/packager/app/test/testdata/hls-only-dash-only-captions/output.mpd new file mode 100644 index 0000000000..f126b6e4b2 --- /dev/null +++ b/packager/app/test/testdata/hls-only-dash-only-captions/output.mpd @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packager/app/test/testdata/hls-only-dash-only-captions/stream_1.m3u8 b/packager/app/test/testdata/hls-only-dash-only-captions/stream_1.m3u8 new file mode 100644 index 0000000000..bca9f92321 --- /dev/null +++ b/packager/app/test/testdata/hls-only-dash-only-captions/stream_1.m3u8 @@ -0,0 +1,16 @@ +#EXTM3U +#EXT-X-VERSION:6 +## Generated with https://github.com/google/shaka-packager version -- +#EXT-X-TARGETDURATION:2 +#EXT-X-PLAYLIST-TYPE:VOD +#EXTINF:1.000, +bear-english-text-1.vtt +#EXTINF:1.000, +bear-english-text-2.vtt +#EXTINF:1.000, +bear-english-text-3.vtt +#EXTINF:1.000, +bear-english-text-4.vtt +#EXTINF:1.000, +bear-english-text-5.vtt +#EXT-X-ENDLIST diff --git a/packager/app/test/testdata/hls-only-dash-only-captions/stream_2.m3u8 b/packager/app/test/testdata/hls-only-dash-only-captions/stream_2.m3u8 new file mode 100644 index 0000000000..a717606102 --- /dev/null +++ b/packager/app/test/testdata/hls-only-dash-only-captions/stream_2.m3u8 @@ -0,0 +1,13 @@ +#EXTM3U +#EXT-X-VERSION:6 +## Generated with https://github.com/google/shaka-packager version -- +#EXT-X-TARGETDURATION:2 +#EXT-X-PLAYLIST-TYPE:VOD +#EXT-X-MAP:URI="bear-640x360-audio-init.mp4" +#EXTINF:1.022, +bear-640x360-audio-1.m4s +#EXTINF:0.998, +bear-640x360-audio-2.m4s +#EXTINF:0.720, +bear-640x360-audio-3.m4s +#EXT-X-ENDLIST diff --git a/packager/app/test/testdata/hls-only-dash-only-captions/stream_3.m3u8 b/packager/app/test/testdata/hls-only-dash-only-captions/stream_3.m3u8 new file mode 100644 index 0000000000..19e29dda02 --- /dev/null +++ b/packager/app/test/testdata/hls-only-dash-only-captions/stream_3.m3u8 @@ -0,0 +1,13 @@ +#EXTM3U +#EXT-X-VERSION:6 +## Generated with https://github.com/google/shaka-packager version -- +#EXT-X-TARGETDURATION:2 +#EXT-X-PLAYLIST-TYPE:VOD +#EXT-X-MAP:URI="bear-640x360-video-init.mp4" +#EXTINF:1.001, +bear-640x360-video-1.m4s +#EXTINF:1.001, +bear-640x360-video-2.m4s +#EXTINF:0.734, +bear-640x360-video-3.m4s +#EXT-X-ENDLIST diff --git a/packager/packager.cc b/packager/packager.cc index 924566537d..259453d37d 100644 --- a/packager/packager.cc +++ b/packager/packager.cc @@ -602,7 +602,7 @@ Status CreateTextJobs( ToMuxerListenerData(stream)); // Check input to ensure that output is possible. - if (hls_listener) { + if (hls_listener && !stream.dash_only) { if (input_container == CONTAINER_TTML) { return Status(error::INVALID_ARGUMENT, "HLS does not support TTML in xml format."); @@ -614,14 +614,15 @@ Status CreateTextJobs( } } - if (mpd_notifier && !stream.segment_template.empty()) { + if (mpd_notifier && !stream.segment_template.empty() && + !stream.hls_only) { return Status(error::INVALID_ARGUMENT, "Cannot create text output for MPD with segment output."); } // If we are outputting to HLS, then create the HLS test pipeline that // will create segmented text output. - if (hls_listener) { + if (hls_listener && !stream.dash_only) { RETURN_IF_ERROR(CreateHlsTextJob(stream, packaging_params, std::move(hls_listener), sync_points, job_manager));