Add HLS playback test with TTML subtitles muxed into MP4

The test is hidden behind the `@Ignore` annotation due to some
flakiness. However, it will be removed when the subtitle parsing is
moved to a pre-sample-queue architecture.

The test media was created with:

```shell
$ cp ../../dash/standalone-ttml/sample.xml sample.ttml
$ MP4Box -add sample.ttml sample.text.mp4
$ MP4Box -frag 10000 sample.text.mp4
$ rm sample.ttml
```

PiperOrigin-RevId: 582347113
This commit is contained in:
jbibik 2023-11-14 09:27:15 -08:00 committed by Copybara-Service
parent 9bf1852069
commit 67f770a786
7 changed files with 291 additions and 0 deletions

View File

@ -32,6 +32,7 @@ import androidx.media3.test.utils.robolectric.ShadowMediaCodecConfig;
import androidx.media3.test.utils.robolectric.TestPlayerRunHelper;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -69,4 +70,29 @@ public final class HlsPlaybackTest {
DumpFileAsserts.assertOutput(
applicationContext, playbackOutput, "playbackdumps/hls/standalone-webvtt.dump");
}
@Test
@Ignore(
"Disabled until subtitles are reliably asserted in robolectric tests [internal b/174661563].")
public void ttmlInMp4() 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);
player.setMediaItem(
MediaItem.fromUri("asset:///media/hls/ttml-in-mp4/multivariant_playlist.m3u8"));
player.prepare();
player.play();
TestPlayerRunHelper.runUntilPlaybackState(player, Player.STATE_ENDED);
player.release();
DumpFileAsserts.assertOutput(
applicationContext, playbackOutput, "playbackdumps/hls/ttml-in-mp4.dump");
}
}

View File

@ -0,0 +1,8 @@
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:1
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-PLAYLIST-TYPE:VOD
#EXTINF:1.001000,
sample.video.mp4
#EXT-X-ENDLIST

View File

@ -0,0 +1,7 @@
#EXTM3U
#EXT-X-INDEPENDENT-SEGMENTS
#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subs",NAME="English",LANGUAGE="en",DEFAULT=YES,URI="playlist_ttml.m3u8"
#EXT-X-STREAM-INF:BANDWIDTH=718000,CODECS="avc1.64001f,stpp.ttml.im1t",SUBTITLES="subs"
media_playlist.m3u8

View File

@ -0,0 +1,7 @@
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:1
#EXT-X-MEDIA-SEQUENCE:0
#EXTINF:1.001000,
sample.text.mp4
#EXT-X-ENDLIST

View File

@ -0,0 +1,243 @@
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 = 250000
Cue[0]:
text = First Subtitle after 20ms of silence
Second Subtitle overlaps with first
Subtitle[2]:
presentationTimeUs = 400000
Cue[0]:
text = First Subtitle after 20ms of silence
Subtitle[3]:
presentationTimeUs = 500000
Cues = []
Subtitle[4]:
presentationTimeUs = 700000
Cue[0]:
text = Last subtitle
And More
Subtitle[5]:
presentationTimeUs = 950000
Cues = []