Skip to content

Commit

Permalink
Add DashPlayback test with sideloaded TTML subtitles
Browse files Browse the repository at this point in the history
The test is hidden behind the Ignore annotation due to some flakiness just like `webvttInMp4`. However, it will be removed when the subtitle parsing is moved to a pre-sample-queue architecture.

#minor-release

PiperOrigin-RevId: 570376275
  • Loading branch information
oceanjules authored and copybara-github committed Oct 3, 2023
1 parent b83f12c commit bd5a392
Show file tree
Hide file tree
Showing 5 changed files with 307 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,34 @@ public final class DashPlaybackTest {
public ShadowMediaCodecConfig mediaCodecConfig =
ShadowMediaCodecConfig.forAllSupportedMimeTypes();

@Test
@Ignore(
"Disabled until subtitles are reliably asserted in robolectric tests [internal b/174661563].")
public void ttmlStandaloneXmlFile() throws Exception {
Context applicationContext = ApplicationProvider.getApplicationContext();
CapturingRenderersFactory capturingRenderersFactory =
new CapturingRenderersFactory(applicationContext);
ExoPlayer player =
new ExoPlayer.Builder(applicationContext, capturingRenderersFactory)
.setClock(new FakeClock(/* isAutoAdvancing= */ true))
.build();
player.setVideoSurface(new Surface(new SurfaceTexture(/* texName= */ 1)));
PlaybackOutput playbackOutput = PlaybackOutput.register(player, capturingRenderersFactory);

// Ensure the subtitle track is selected.
DefaultTrackSelector trackSelector =
checkNotNull((DefaultTrackSelector) player.getTrackSelector());
trackSelector.setParameters(trackSelector.buildUponParameters().setPreferredTextLanguage("en"));
player.setMediaItem(MediaItem.fromUri("asset:///media/dash/ttml-in-mp4/sample.mpd"));
player.prepare();
player.play();
TestPlayerRunHelper.runUntilPlaybackState(player, Player.STATE_ENDED);
player.release();

DumpFileAsserts.assertOutput(
applicationContext, playbackOutput, "playbackdumps/dash/ttml-in-mp4.dump");
}

// https://github.com/google/ExoPlayer/issues/7985
@Test
@Ignore(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<MPD type="static" duration="1s" mediaPresentationDuration="PT1S">
<Period>
<AdaptationSet id="0" mimeType="application/ttml+xml" subsegmentAlignment="true" lang="eng">
<Role schemeIdUri="urn:mpeg:dash:role:2011" value="subtitle"/>
<Representation id="0" bandwidth="16">
<BaseURL>sample.xml</BaseURL>
</Representation>
</AdaptationSet>
<AdaptationSet id="1" contentType="video" width="1080" height="720" frameRate="30000/1001" subsegmentAlignment="true" par="3:2">
<Representation id="1" bandwidth="721967" codecs="avc1.64001f" mimeType="video/mp4" sar="1:1">
<BaseURL>sample.video.mp4</BaseURL>
<SegmentBase indexRange="862-905" timescale="30000">
<Initialization range="0-861"/>
</SegmentBase>
</Representation>
</AdaptationSet>
</Period>
</MPD>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<tt xmlns="http://www.w3.org/ns/ttml">
<body>
<div>
<p begin="00:00:00.020" end="00:00:00.500">First Subtitle after 20ms of silence</p>
</div>
<div>
<p begin="00:00:00.250" end="00:00:00.400">Second Subtitle overlaps with first</p>
</div>
<div>
<p begin="00:00:00.700" end="00:00:00.950">Last subtitle<br/>And More</p>
</div>
</body>
</tt>
Original file line number Diff line number Diff line change
@@ -0,0 +1,247 @@
MediaCodecAdapter (exotest.video.avc):
inputBuffers:
count = 31
input buffer #0:
timeUs = 1000000000000
contents = length 36692, hash D216076E
input buffer #1:
timeUs = 1000000066733
contents = length 5312, hash D45D3CA0
input buffer #2:
timeUs = 1000000033366
contents = length 599, hash 1BE7812D
input buffer #3:
timeUs = 1000000200200
contents = length 7735, hash 4490F110
input buffer #4:
timeUs = 1000000133466
contents = length 987, hash 560B5036
input buffer #5:
timeUs = 1000000100100
contents = length 673, hash ED7CD8C7
input buffer #6:
timeUs = 1000000166833
contents = length 523, hash 3020DF50
input buffer #7:
timeUs = 1000000333666
contents = length 6061, hash 736C72B2
input buffer #8:
timeUs = 1000000266933
contents = length 992, hash FE132F23
input buffer #9:
timeUs = 1000000233566
contents = length 623, hash 5B2C1816
input buffer #10:
timeUs = 1000000300300
contents = length 421, hash 742E69C1
input buffer #11:
timeUs = 1000000433766
contents = length 4899, hash F72F86A1
input buffer #12:
timeUs = 1000000400400
contents = length 568, hash 519A8E50
input buffer #13:
timeUs = 1000000367033
contents = length 620, hash 3990AA39
input buffer #14:
timeUs = 1000000567233
contents = length 5450, hash F06EC4AA
input buffer #15:
timeUs = 1000000500500
contents = length 1051, hash 92DFA63A
input buffer #16:
timeUs = 1000000467133
contents = length 874, hash 69587FB4
input buffer #17:
timeUs = 1000000533866
contents = length 781, hash 36BE495B
input buffer #18:
timeUs = 1000000700700
contents = length 4725, hash AC0C8CD3
input buffer #19:
timeUs = 1000000633966
contents = length 1022, hash 5D8BFF34
input buffer #20:
timeUs = 1000000600600
contents = length 790, hash 99413A99
input buffer #21:
timeUs = 1000000667333
contents = length 610, hash 5E129290
input buffer #22:
timeUs = 1000000834166
contents = length 2751, hash 769974CB
input buffer #23:
timeUs = 1000000767433
contents = length 745, hash B78A477A
input buffer #24:
timeUs = 1000000734066
contents = length 621, hash CF741E7A
input buffer #25:
timeUs = 1000000800800
contents = length 505, hash 1DB4894E
input buffer #26:
timeUs = 1000000967633
contents = length 1268, hash C15348DC
input buffer #27:
timeUs = 1000000900900
contents = length 880, hash C2DE85D0
input buffer #28:
timeUs = 1000000867533
contents = length 530, hash C98BC6A8
input buffer #29:
timeUs = 1000000934266
contents = length 568, hash 4FE5C8EA
input buffer #30:
timeUs = 0
flags = 4
contents = length 0, hash 1
outputBuffers:
count = 30
output buffer #0:
timeUs = 1000000000000
size = 36692
rendered = true
output buffer #1:
timeUs = 1000000066733
size = 5312
rendered = true
output buffer #2:
timeUs = 1000000033366
size = 599
rendered = true
output buffer #3:
timeUs = 1000000200200
size = 7735
rendered = true
output buffer #4:
timeUs = 1000000133466
size = 987
rendered = true
output buffer #5:
timeUs = 1000000100100
size = 673
rendered = true
output buffer #6:
timeUs = 1000000166833
size = 523
rendered = true
output buffer #7:
timeUs = 1000000333666
size = 6061
rendered = true
output buffer #8:
timeUs = 1000000266933
size = 992
rendered = true
output buffer #9:
timeUs = 1000000233566
size = 623
rendered = true
output buffer #10:
timeUs = 1000000300300
size = 421
rendered = true
output buffer #11:
timeUs = 1000000433766
size = 4899
rendered = true
output buffer #12:
timeUs = 1000000400400
size = 568
rendered = true
output buffer #13:
timeUs = 1000000367033
size = 620
rendered = true
output buffer #14:
timeUs = 1000000567233
size = 5450
rendered = true
output buffer #15:
timeUs = 1000000500500
size = 1051
rendered = true
output buffer #16:
timeUs = 1000000467133
size = 874
rendered = true
output buffer #17:
timeUs = 1000000533866
size = 781
rendered = true
output buffer #18:
timeUs = 1000000700700
size = 4725
rendered = true
output buffer #19:
timeUs = 1000000633966
size = 1022
rendered = true
output buffer #20:
timeUs = 1000000600600
size = 790
rendered = true
output buffer #21:
timeUs = 1000000667333
size = 610
rendered = true
output buffer #22:
timeUs = 1000000834166
size = 2751
rendered = true
output buffer #23:
timeUs = 1000000767433
size = 745
rendered = true
output buffer #24:
timeUs = 1000000734066
size = 621
rendered = true
output buffer #25:
timeUs = 1000000800800
size = 505
rendered = true
output buffer #26:
timeUs = 1000000967633
size = 1268
rendered = true
output buffer #27:
timeUs = 1000000900900
size = 880
rendered = true
output buffer #28:
timeUs = 1000000867533
size = 530
rendered = true
output buffer #29:
timeUs = 1000000934266
size = 568
rendered = true
TextOutput:
Subtitle[0]:
presentationTimeUs = 0
Cues = []
Subtitle[1]:
presentationTimeUs = 20000
Cue[0]:
text = First Subtitle after 20ms of silence
Subtitle[2]:
presentationTimeUs = 250000
Cue[0]:
text = First Subtitle after 20ms of silence
Second Subtitle overlaps with first
Subtitle[3]:
presentationTimeUs = 400000
Cue[0]:
text = First Subtitle after 20ms of silence
Subtitle[4]:
presentationTimeUs = 500000
Cues = []
Subtitle[5]:
presentationTimeUs = 700000
Cue[0]:
text = Last subtitle
And More
Subtitle[6]:
presentationTimeUs = 950000
Cues = []

0 comments on commit bd5a392

Please sign in to comment.