[WEBVTT] Fix missing text alignment tags from output

Legacy players, e.g. older versions of ExoPlayer, do not handle default webvtt text alignment correctly. Need to specify `align:center` explicitly cues without text alignment for backwards compatibility.

Fixes #925.
This commit is contained in:
Vishal Shah 2021-05-04 22:57:43 -07:00 committed by GitHub
parent 37b16b4091
commit d9124d6aaa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
61 changed files with 48 additions and 46 deletions

View File

@ -3,9 +3,9 @@ WEBVTT
STYLE
::cue { color:lime }
00:00:00.000 --> 00:00:00.800
00:00:00.000 --> 00:00:00.800 align:center
Yup, that's a bear, eh.
00:00:01.000 --> 00:00:04.700
00:00:01.000 --> 00:00:04.700 align:center
He 's... um... doing bear-like stuff.

View File

@ -23,7 +23,7 @@
</AdaptationSet>
<AdaptationSet id="2" contentType="text" subsegmentAlignment="true">
<Role schemeIdUri="urn:mpeg:dash:role:2011" value="caption"/>
<Representation id="2" bandwidth="273" mimeType="text/vtt">
<Representation id="2" bandwidth="317" mimeType="text/vtt">
<BaseURL>bear-english-text.vtt</BaseURL>
</Representation>
</AdaptationSet>

View File

@ -3,6 +3,6 @@ WEBVTT
STYLE
::cue { color:lime }
00:00:00.000 --> 00:00:00.800
00:00:00.000 --> 00:00:00.800 align:center
Yup, that's a bear, eh.

View File

@ -3,6 +3,6 @@ WEBVTT
STYLE
::cue { color:lime }
00:00:01.000 --> 00:00:04.700
00:00:01.000 --> 00:00:04.700 align:center
He 's... um... doing bear-like stuff.

View File

@ -3,6 +3,6 @@ WEBVTT
STYLE
::cue { color:lime }
00:00:01.000 --> 00:00:04.700
00:00:01.000 --> 00:00:04.700 align:center
He 's... um... doing bear-like stuff.

View File

@ -3,6 +3,6 @@ WEBVTT
STYLE
::cue { color:lime }
00:00:01.000 --> 00:00:04.700
00:00:01.000 --> 00:00:04.700 align:center
He 's... um... doing bear-like stuff.

View File

@ -3,6 +3,6 @@ WEBVTT
STYLE
::cue { color:lime }
00:00:01.000 --> 00:00:04.700
00:00:01.000 --> 00:00:04.700 align:center
He 's... um... doing bear-like stuff.

View File

@ -3,6 +3,6 @@ WEBVTT
STYLE
::cue { color:lime }
00:00:01.000 --> 00:00:04.700
00:00:01.000 --> 00:00:04.700 align:center
He 's... um... doing bear-like stuff.

View File

@ -3,6 +3,6 @@ WEBVTT
STYLE
::cue { color:lime }
00:00:00.000 --> 00:00:00.800
00:00:00.000 --> 00:00:00.800 align:center
Yup, that's a bear, eh.

View File

@ -3,6 +3,6 @@ WEBVTT
STYLE
::cue { color:lime }
00:00:01.000 --> 00:00:04.700
00:00:01.000 --> 00:00:04.700 align:center
He 's... um... doing bear-like stuff.

View File

@ -3,6 +3,6 @@ WEBVTT
STYLE
::cue { color:lime }
00:00:01.000 --> 00:00:04.700
00:00:01.000 --> 00:00:04.700 align:center
He 's... um... doing bear-like stuff.

View File

@ -3,6 +3,6 @@ WEBVTT
STYLE
::cue { color:lime }
00:00:01.000 --> 00:00:04.700
00:00:01.000 --> 00:00:04.700 align:center
He 's... um... doing bear-like stuff.

View File

@ -3,6 +3,6 @@ WEBVTT
STYLE
::cue { color:lime }
00:00:01.000 --> 00:00:04.700
00:00:01.000 --> 00:00:04.700 align:center
He 's... um... doing bear-like stuff.

View File

@ -26,7 +26,7 @@
</AdaptationSet>
<AdaptationSet id="2" contentType="text" segmentAlignment="true">
<Role schemeIdUri="urn:mpeg:dash:role:2011" value="subtitle"/>
<Representation id="2" bandwidth="2056" codecs="wvtt" mimeType="application/mp4">
<Representation id="2" bandwidth="2216" codecs="wvtt" mimeType="application/mp4">
<SegmentTemplate timescale="1000" initialization="bear-english-text-init.mp4" media="bear-english-text-$Number$.m4s" startNumber="1">
<SegmentTimeline>
<S t="0" d="1000" r="4"/>

View File

@ -4,6 +4,6 @@ X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:9000
STYLE
::cue { color:lime }
00:00:00.000 --> 00:00:00.800
00:00:00.000 --> 00:00:00.800 align:center
Yup, that's a bear, eh.

View File

@ -4,6 +4,6 @@ X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:9000
STYLE
::cue { color:lime }
00:00:01.000 --> 00:00:04.700
00:00:01.000 --> 00:00:04.700 align:center
He 's... um... doing bear-like stuff.

View File

@ -4,6 +4,6 @@ X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:9000
STYLE
::cue { color:lime }
00:00:01.000 --> 00:00:04.700
00:00:01.000 --> 00:00:04.700 align:center
He 's... um... doing bear-like stuff.

View File

@ -4,6 +4,6 @@ X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:9000
STYLE
::cue { color:lime }
00:00:01.000 --> 00:00:04.700
00:00:01.000 --> 00:00:04.700 align:center
He 's... um... doing bear-like stuff.

View File

@ -4,6 +4,6 @@ X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:9000
STYLE
::cue { color:lime }
00:00:01.000 --> 00:00:04.700
00:00:01.000 --> 00:00:04.700 align:center
He 's... um... doing bear-like stuff.

View File

@ -4,7 +4,7 @@
<Period id="0" start="PT0S">
<AdaptationSet id="0" contentType="text" segmentAlignment="true">
<Role schemeIdUri="urn:mpeg:dash:role:2011" value="subtitle"/>
<Representation id="0" bandwidth="2056" codecs="wvtt" mimeType="application/mp4">
<Representation id="0" bandwidth="2216" codecs="wvtt" mimeType="application/mp4">
<SegmentTemplate timescale="1000" initialization="bear-english-text-init.mp4" media="bear-english-text-$Number$.m4s" startNumber="1">
<SegmentTimeline>
<S t="0" d="1000" r="4"/>

View File

@ -4,6 +4,6 @@ X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:9000
STYLE
::cue { color:lime }
00:00:00.000 --> 00:00:00.800
00:00:00.000 --> 00:00:00.800 align:center
Yup, that's a bear, eh.

View File

@ -4,6 +4,6 @@ X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:9000
STYLE
::cue { color:lime }
00:00:01.000 --> 00:00:04.700
00:00:01.000 --> 00:00:04.700 align:center
He 's... um... doing bear-like stuff.

View File

@ -4,6 +4,6 @@ X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:9000
STYLE
::cue { color:lime }
00:00:01.000 --> 00:00:04.700
00:00:01.000 --> 00:00:04.700 align:center
He 's... um... doing bear-like stuff.

View File

@ -4,6 +4,6 @@ X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:9000
STYLE
::cue { color:lime }
00:00:01.000 --> 00:00:04.700
00:00:01.000 --> 00:00:04.700 align:center
He 's... um... doing bear-like stuff.

View File

@ -4,6 +4,6 @@ X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:9000
STYLE
::cue { color:lime }
00:00:01.000 --> 00:00:04.700
00:00:01.000 --> 00:00:04.700 align:center
He 's... um... doing bear-like stuff.

View File

@ -4,7 +4,7 @@
<Period id="0" start="PT0S">
<AdaptationSet id="0" contentType="text" segmentAlignment="true">
<Role schemeIdUri="urn:mpeg:dash:role:2011" value="subtitle"/>
<Representation id="0" bandwidth="1216" mimeType="text/vtt">
<Representation id="0" bandwidth="1320" mimeType="text/vtt">
<SegmentTemplate timescale="1000" media="bear-english-text-$Number$.vtt" startNumber="1">
<SegmentTimeline>
<S t="0" d="1000" r="4"/>

View File

@ -3,6 +3,6 @@ WEBVTT
STYLE
::cue { color:lime }
00:00:00.000 --> 00:00:00.800
00:00:00.000 --> 00:00:00.800 align:center
Yup, that's a bear, eh.

View File

@ -3,6 +3,6 @@ WEBVTT
STYLE
::cue { color:lime }
00:00:01.000 --> 00:00:04.700
00:00:01.000 --> 00:00:04.700 align:center
He 's... um... doing bear-like stuff.

View File

@ -3,6 +3,6 @@ WEBVTT
STYLE
::cue { color:lime }
00:00:01.000 --> 00:00:04.700
00:00:01.000 --> 00:00:04.700 align:center
He 's... um... doing bear-like stuff.

View File

@ -3,6 +3,6 @@ WEBVTT
STYLE
::cue { color:lime }
00:00:01.000 --> 00:00:04.700
00:00:01.000 --> 00:00:04.700 align:center
He 's... um... doing bear-like stuff.

View File

@ -3,6 +3,6 @@ WEBVTT
STYLE
::cue { color:lime }
00:00:01.000 --> 00:00:04.700
00:00:01.000 --> 00:00:04.700 align:center
He 's... um... doing bear-like stuff.

View File

@ -4,7 +4,7 @@
<Period id="0" start="PT0S">
<AdaptationSet id="0" contentType="text" lang="pt" segmentAlignment="true">
<Role schemeIdUri="urn:mpeg:dash:role:2011" value="subtitle"/>
<Representation id="0" bandwidth="2056" codecs="wvtt" mimeType="application/mp4">
<Representation id="0" bandwidth="2216" codecs="wvtt" mimeType="application/mp4">
<SegmentTemplate timescale="1000" initialization="bear-english-text-init.mp4" media="bear-english-text-$Number$.m4s" startNumber="1">
<SegmentTimeline>
<S t="0" d="1000" r="4"/>

View File

@ -4,9 +4,9 @@ X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:9000
STYLE
::cue { color:lime }
00:00:00.000 --> 00:00:00.800
00:00:00.000 --> 00:00:00.800 align:center
Yup, that's a bear, eh.
00:00:01.000 --> 00:00:04.700
00:00:01.000 --> 00:00:04.700 align:center
He 's... um... doing bear-like stuff.

View File

@ -4,7 +4,7 @@
<Period id="0">
<AdaptationSet id="0" contentType="text" subsegmentAlignment="true">
<Role schemeIdUri="urn:mpeg:dash:role:2011" value="subtitle"/>
<Representation id="0" bandwidth="353" mimeType="text/vtt">
<Representation id="0" bandwidth="397" mimeType="text/vtt">
<BaseURL>bear-english-text.vtt</BaseURL>
</Representation>
</AdaptationSet>

View File

@ -3,9 +3,9 @@ WEBVTT
STYLE
::cue { color:lime }
00:00:00.000 --> 00:00:00.800
00:00:00.000 --> 00:00:00.800 align:center
Yup, that's a bear, eh.
00:00:01.000 --> 00:00:04.700
00:00:01.000 --> 00:00:04.700 align:center
He 's... um... doing bear-like stuff.

View File

@ -21,7 +21,7 @@
</AdaptationSet>
<AdaptationSet id="2" contentType="text" subsegmentAlignment="true">
<Role schemeIdUri="urn:mpeg:dash:role:2011" value="subtitle"/>
<Representation id="2" bandwidth="273" mimeType="text/vtt">
<Representation id="2" bandwidth="317" mimeType="text/vtt">
<BaseURL>bear-english-text.vtt</BaseURL>
</Representation>
</AdaptationSet>

View File

@ -24,7 +24,7 @@
</AdaptationSet>
<AdaptationSet id="2" contentType="text" segmentAlignment="true">
<Role schemeIdUri="urn:mpeg:dash:role:2011" value="subtitle"/>
<Representation id="2" bandwidth="1944" codecs="wvtt" mimeType="application/mp4">
<Representation id="2" bandwidth="2104" codecs="wvtt" mimeType="application/mp4">
<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"/>
@ -56,7 +56,7 @@
</AdaptationSet>
<AdaptationSet id="2" contentType="text" segmentAlignment="true">
<Role schemeIdUri="urn:mpeg:dash:role:2011" value="subtitle"/>
<Representation id="2" bandwidth="2056" codecs="wvtt" mimeType="application/mp4">
<Representation id="2" bandwidth="2216" codecs="wvtt" mimeType="application/mp4">
<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"/>

View File

@ -83,7 +83,7 @@ TEST_F(WebVttMuxerTest, WithOneSegmentAndWithOneSample) {
const char* kExpectedOutput =
"WEBVTT\n"
"\n"
"00:00:05.000 --> 00:00:06.000\n"
"00:00:05.000 --> 00:00:06.000 align:center\n"
"payload\n"
"\n";
@ -122,14 +122,14 @@ TEST_F(WebVttMuxerTest, WithTwoSegmentAndWithOneSample) {
const char* kExpectedOutput1 =
"WEBVTT\n"
"\n"
"00:00:05.000 --> 00:00:06.000\n"
"00:00:05.000 --> 00:00:06.000 align:center\n"
"payload 1\n"
"\n";
const char* kExpectedOutput2 =
"WEBVTT\n"
"\n"
"00:00:15.000 --> 00:00:16.000\n"
"00:00:15.000 --> 00:00:16.000 align:center\n"
"payload 2\n"
"\n";
@ -189,7 +189,7 @@ TEST_F(WebVttMuxerTest, WithAnEmptySegment) {
const char* kExpectedOutput2 =
"WEBVTT\n"
"\n"
"00:00:15.000 --> 00:00:16.000\n"
"00:00:15.000 --> 00:00:16.000 align:center\n"
"payload 2\n"
"\n";

View File

@ -249,6 +249,7 @@ std::string WebVttSettingsToString(const TextSettings& settings) {
ret += " align:right";
break;
case TextAlignment::kCenter:
ret += " align:center";
break;
}

View File

@ -163,9 +163,10 @@ TEST(WebVttUtilsTest, SettingsToString) {
TEST(WebVttUtilsTest, SettingsToString_IgnoresDefaults) {
TextSettings settings;
settings.region = "foo";
settings.text_alignment = TextAlignment::kCenter;
const auto actual = WebVttSettingsToString(settings);
EXPECT_EQ(actual, "region:foo");
EXPECT_EQ(actual, "region:foo align:center");
}
TEST(WebVttUtilsTest, FragmentToString) {