Skip to content

Commit

Permalink
[DASH] Fix TTML text input passthrough (regression)
Browse files Browse the repository at this point in the history
Note that TTML in ISO-BMFF is not supported yet.

Also updated packager_test.py:
- Added a test using TTML passthrough.
- Computed output extension from input extension unless output_format
  is specified.

Fixes #478.

Change-Id: Ia917fc4ed3c326782791ed67601fba02ea28b11d
  • Loading branch information
kqyang committed Sep 19, 2018
1 parent 5a91281 commit 42083d2
Show file tree
Hide file tree
Showing 37 changed files with 209 additions and 249 deletions.
234 changes: 88 additions & 146 deletions packager/app/test/packager_test.py

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
#EXT-X-TARGETDURATION:2
#EXT-X-PLAYLIST-TYPE:VOD
#EXTINF:1.000,
bear-subtitle-english-text-1.vtt
bear-english-text-1.vtt
#EXTINF:1.000,
bear-subtitle-english-text-2.vtt
bear-english-text-2.vtt
#EXTINF:0.001,
bear-subtitle-english-text-3.vtt
bear-english-text-3.vtt
#EXT-X-PLACEMENT-OPPORTUNITY
#EXTINF:1.000,
bear-subtitle-english-text-4.vtt
bear-english-text-4.vtt
#EXTINF:1.000,
bear-subtitle-english-text-5.vtt
bear-english-text-5.vtt
#EXTINF:1.000,
bear-subtitle-english-text-6.vtt
bear-english-text-6.vtt
#EXT-X-ENDLIST
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#EXT-X-MEDIA:TYPE=AUDIO,URI="bear-640x360-audio.m3u8",GROUP-ID="default-audio-group",NAME="stream_1",AUTOSELECT=YES,CHANNELS="2"

#EXT-X-MEDIA:TYPE=SUBTITLES,URI="bear-subtitle-english-text.m3u8",GROUP-ID="default-text-group",NAME="stream_0",AUTOSELECT=YES
#EXT-X-MEDIA:TYPE=SUBTITLES,URI="bear-english-text.m3u8",GROUP-ID="default-text-group",NAME="stream_0",AUTOSELECT=YES

#EXT-X-STREAM-INF:BANDWIDTH=1108051,AVERAGE-BANDWIDTH=1005999,CODECS="avc1.64001e,mp4a.40.2",RESOLUTION=640x360,AUDIO="default-audio-group",SUBTITLES="default-text-group"
bear-640x360-video.m3u8
Expand Down
10 changes: 5 additions & 5 deletions packager/app/test/testdata/hls-segmented-webvtt/stream_0.m3u8
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
#EXT-X-TARGETDURATION:2
#EXT-X-PLAYLIST-TYPE:VOD
#EXTINF:1.000,
bear-subtitle-english-text-1.vtt
bear-english-text-1.vtt
#EXTINF:1.000,
bear-subtitle-english-text-2.vtt
bear-english-text-2.vtt
#EXTINF:1.000,
bear-subtitle-english-text-3.vtt
bear-english-text-3.vtt
#EXTINF:1.000,
bear-subtitle-english-text-4.vtt
bear-english-text-4.vtt
#EXTINF:1.000,
bear-subtitle-english-text-5.vtt
bear-english-text-5.vtt
#EXT-X-ENDLIST
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<tt xmlns="http://www.w3.org/ns/ttml" xml:lang="en">
<body>
<div>
<p begin="0.1s" end="0.8s">Yup, that's a bear, eh.</p>
<p begin="1.0s" end="4.7s">He 's... um... doing bear-like stuff.</p>
</div>
</body>
</tt>
28 changes: 28 additions & 0 deletions packager/app/test/testdata/video-audio-ttml/output.mpd
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--Generated with https://github.com/google/shaka-packager version <tag>-<hash>-<test>-->
<MPD xmlns="urn:mpeg:dash:schema:mpd:2011" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink" xsi:schemaLocation="urn:mpeg:dash:schema:mpd:2011 DASH-MPD.xsd" xmlns:cenc="urn:mpeg:cenc:2013" profiles="urn:mpeg:dash:profile:isoff-on-demand:2011" minBufferTime="PT2S" type="static" mediaPresentationDuration="PT2.7360665798187256S">
<Period id="0">
<AdaptationSet id="0" contentType="text" subsegmentAlignment="true">
<Representation id="0" bandwidth="256" mimeType="application/ttml+xml">
<BaseURL>bear-english-text.ttml</BaseURL>
</Representation>
</AdaptationSet>
<AdaptationSet id="1" contentType="video" width="640" height="360" frameRate="30000/1001" subsegmentAlignment="true" par="16:9">
<Representation id="1" bandwidth="973483" codecs="avc1.64001e" mimeType="video/mp4" sar="1:1">
<BaseURL>bear-640x360-video.mp4</BaseURL>
<SegmentBase indexRange="859-926" timescale="30000">
<Initialization range="0-858"/>
</SegmentBase>
</Representation>
</AdaptationSet>
<AdaptationSet id="2" contentType="audio" subsegmentAlignment="true">
<Representation id="2" bandwidth="133334" codecs="mp4a.40.2" mimeType="audio/mp4" audioSamplingRate="44100">
<AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2"/>
<BaseURL>bear-640x360-audio.mp4</BaseURL>
<SegmentBase indexRange="793-860" timescale="44100">
<Initialization range="0-792"/>
</SegmentBase>
</Representation>
</AdaptationSet>
</Period>
</MPD>
Binary file not shown.
Binary file not shown.
28 changes: 28 additions & 0 deletions packager/app/test/testdata/video-audio-webvtt/output.mpd
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--Generated with https://github.com/google/shaka-packager version <tag>-<hash>-<test>-->
<MPD xmlns="urn:mpeg:dash:schema:mpd:2011" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink" xsi:schemaLocation="urn:mpeg:dash:schema:mpd:2011 DASH-MPD.xsd" xmlns:cenc="urn:mpeg:cenc:2013" profiles="urn:mpeg:dash:profile:isoff-on-demand:2011" minBufferTime="PT2S" type="static" mediaPresentationDuration="PT2.7360665798187256S">
<Period id="0">
<AdaptationSet id="0" contentType="text" subsegmentAlignment="true">
<Representation id="0" bandwidth="256" mimeType="text/vtt">
<BaseURL>bear-english-text.vtt</BaseURL>
</Representation>
</AdaptationSet>
<AdaptationSet id="1" contentType="video" width="640" height="360" frameRate="30000/1001" subsegmentAlignment="true" par="16:9">
<Representation id="1" bandwidth="973483" codecs="avc1.64001e" mimeType="video/mp4" sar="1:1">
<BaseURL>bear-640x360-video.mp4</BaseURL>
<SegmentBase indexRange="859-926" timescale="30000">
<Initialization range="0-858"/>
</SegmentBase>
</Representation>
</AdaptationSet>
<AdaptationSet id="2" contentType="audio" subsegmentAlignment="true">
<Representation id="2" bandwidth="133334" codecs="mp4a.40.2" mimeType="audio/mp4" audioSamplingRate="44100">
<AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2"/>
<BaseURL>bear-640x360-audio.mp4</BaseURL>
<SegmentBase indexRange="793-860" timescale="44100">
<Initialization range="0-792"/>
</SegmentBase>
</Representation>
</AdaptationSet>
</Period>
</MPD>
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
## Generated with https://github.com/google/shaka-packager version <tag>-<hash>-<test>
#EXT-X-TARGETDURATION:2
#EXT-X-PLAYLIST-TYPE:VOD
#EXT-X-MAP:URI="bear-subtitle-english-text-init.mp4"
#EXT-X-MAP:URI="bear-english-text-init.mp4"
#EXTINF:1.000,
bear-subtitle-english-text-1.m4s
bear-english-text-1.m4s
#EXTINF:1.000,
bear-subtitle-english-text-2.m4s
bear-english-text-2.m4s
#EXTINF:0.001,
bear-subtitle-english-text-3.m4s
bear-english-text-3.m4s
#EXT-X-PLACEMENT-OPPORTUNITY
#EXTINF:1.000,
bear-subtitle-english-text-4.m4s
bear-english-text-4.m4s
#EXTINF:1.000,
bear-subtitle-english-text-5.m4s
bear-english-text-5.m4s
#EXTINF:1.000,
bear-subtitle-english-text-6.m4s
bear-english-text-6.m4s
#EXT-X-ENDLIST
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#EXT-X-MEDIA:TYPE=AUDIO,URI="bear-640x360-audio.m3u8",GROUP-ID="default-audio-group",NAME="stream_1",AUTOSELECT=YES,CHANNELS="2"

#EXT-X-MEDIA:TYPE=SUBTITLES,URI="bear-subtitle-english-text.m3u8",GROUP-ID="default-text-group",NAME="stream_0",AUTOSELECT=YES
#EXT-X-MEDIA:TYPE=SUBTITLES,URI="bear-english-text.m3u8",GROUP-ID="default-text-group",NAME="stream_0",AUTOSELECT=YES

#EXT-X-STREAM-INF:BANDWIDTH=1108051,AVERAGE-BANDWIDTH=1005999,CODECS="avc1.64001e,mp4a.40.2",RESOLUTION=640x360,AUDIO="default-audio-group",SUBTITLES="default-text-group"
bear-640x360-video.m3u8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<AdaptationSet id="0" contentType="text" segmentAlignment="true">
<Role schemeIdUri="urn:mpeg:dash:role:2011" value="subtitle"/>
<Representation id="0" bandwidth="1896000" codecs="wvtt" mimeType="application/mp4">
<SegmentTemplate timescale="1000" initialization="bear-subtitle-english-text-init.mp4" media="bear-subtitle-english-text-$Number$.m4s" startNumber="1">
<SegmentTemplate timescale="1000" initialization="bear-english-text-init.mp4" media="bear-english-text-$Number$.m4s" startNumber="1">
<SegmentTimeline>
<S t="0" d="1000" r="1"/>
<S t="2000" d="1"/>
Expand Down Expand Up @@ -38,7 +38,7 @@
<AdaptationSet id="0" contentType="text" segmentAlignment="true">
<Role schemeIdUri="urn:mpeg:dash:role:2011" value="subtitle"/>
<Representation id="0" bandwidth="2024" codecs="wvtt" mimeType="application/mp4">
<SegmentTemplate timescale="1000" presentationTimeOffset="2001" initialization="bear-subtitle-english-text-init.mp4" media="bear-subtitle-english-text-$Number$.m4s" startNumber="4">
<SegmentTemplate timescale="1000" presentationTimeOffset="2001" initialization="bear-english-text-init.mp4" media="bear-english-text-$Number$.m4s" startNumber="4">
<SegmentTimeline>
<S t="2001" d="1000" r="2"/>
</SegmentTimeline>
Expand Down
9 changes: 9 additions & 0 deletions packager/media/test/data/bear-english.ttml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<tt xmlns="http://www.w3.org/ns/ttml" xml:lang="en">
<body>
<div>
<p begin="0.1s" end="0.8s">Yup, that's a bear, eh.</p>
<p begin="1.0s" end="4.7s">He 's... um... doing bear-like stuff.</p>
</div>
</body>
</tt>
10 changes: 10 additions & 0 deletions packager/media/test/data/bear-english.vtt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
WEBVTT
STYLE
::cue { color:lime }
00:00:00.000 --> 00:00:00.800
Yup, that's a bear, eh.

00:00:01.000 --> 00:00:04.700
He 's... um... doing bear-like stuff.
79 changes: 0 additions & 79 deletions packager/media/test/data/subtitle-english.vtt

This file was deleted.

17 changes: 15 additions & 2 deletions packager/packager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -536,20 +536,29 @@ Status CreateTextJobs(
DCHECK(muxer_listener_factory);
DCHECK(job_manager);
for (const StreamDescriptor& stream : streams) {
// There are currently four options:
// There are currently options:
// TEXT TTML --> TEXT TTML [ supported ], for DASH only.
// TEXT WEBVTT --> TEXT WEBVTT [ supported ]
// TEXT WEBVTT --> MP4 WEBVTT [ supported ]
// MP4 WEBVTT --> MP4 WEBVTT [ unsupported ]
// MP4 WEBVTT --> TEXT WEBVTT [ unsupported ]
const auto input_container = DetermineContainerFromFileName(stream.input);
const auto output_container = GetOutputFormat(stream);

if (input_container != CONTAINER_WEBVTT) {
if (input_container != CONTAINER_WEBVTT &&
input_container != CONTAINER_TTML) {
return Status(error::INVALID_ARGUMENT,
"Text output format is not support for " + stream.input);
}

if (output_container == CONTAINER_MOV) {
if (input_container == CONTAINER_TTML) {
return Status(error::INVALID_ARGUMENT,
"TTML in MP4 is not supported yet. Please follow "
"https://github.com/google/shaka-packager/issues/87 for "
"the updates.");
}

std::unique_ptr<MuxerListener> muxer_listener =
muxer_listener_factory->CreateListener(ToMuxerListenerData(stream));

Expand All @@ -566,6 +575,10 @@ Status CreateTextJobs(

// Check input to ensure that output is possible.
if (hls_listener) {
if (input_container == CONTAINER_TTML) {
return Status(error::INVALID_ARGUMENT,
"HLS does not support TTML in xml format.");
}
if (stream.segment_template.empty() || !stream.output.empty()) {
return Status(error::INVALID_ARGUMENT,
"segment_template needs to be specified for HLS text "
Expand Down

0 comments on commit 42083d2

Please # to comment.