Skip to content

Commit

Permalink
Consider DASH stream descriptor field "roles" for WebVTT text streams. (
Browse files Browse the repository at this point in the history
#740)

Fixes #708.
  • Loading branch information
sr1990 authored and kqyang committed Mar 29, 2020
1 parent 82bc7a3 commit 2f31bea
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
5 changes: 5 additions & 0 deletions packager/app/test/packager_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,11 @@ def testAudioVideoWithAccessibilitiesAndRoles(self):
self._GetStream('video'),
]

streams += self._GetStreams(
['text'],
test_files=['bear-english.vtt'],
dash_roles='caption')

self.assertPackageSuccess(streams, self._GetFlags(output_dash=True))
self._CheckTestResults('audio-video-with-accessibilities-and-roles')

Expand Down
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.
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,24 @@
<!--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" xsi:schemaLocation="urn:mpeg:dash:schema:mpd:2011 DASH-MPD.xsd" profiles="urn:mpeg:dash:profile:isoff-on-demand:2011" minBufferTime="PT2S" type="static" mediaPresentationDuration="PT2.7360665798187256S">
<Period id="0">
<AdaptationSet id="0" contentType="video" width="640" height="360" frameRate="30000/1001" subsegmentAlignment="true" par="16:9">
<Representation id="0" bandwidth="973483" codecs="avc1.64001e" mimeType="video/mp4" sar="1:1">
<AdaptationSet id="0" contentType="text" subsegmentAlignment="true">
<Role schemeIdUri="urn:mpeg:dash:role:2011" value="caption"/>
<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="1" contentType="audio" subsegmentAlignment="true">
<AdaptationSet id="2" contentType="audio" subsegmentAlignment="true">
<Accessibility schemeIdUri="urn:tva:metadata:cs:AudioPurposeCS:2007" value="1"/>
<Role schemeIdUri="urn:mpeg:dash:role:2011" value="alternate"/>
<Representation id="1" bandwidth="133334" codecs="mp4a.40.2" mimeType="audio/mp4" audioSamplingRate="44100">
<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">
Expand Down
6 changes: 6 additions & 0 deletions packager/packager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,12 @@ bool StreamInfoToTextMediaInfo(const StreamDescriptor& stream_descriptor,
text_media_info->set_bandwidth(kDefaultTextBandwidth);
}

if (!stream_descriptor.dash_roles.empty()) {
for (const auto& dash_role : stream_descriptor.dash_roles) {
text_media_info->add_dash_roles(dash_role);
}
}

return true;
}

Expand Down

0 comments on commit 2f31bea

Please sign in to comment.