Remove duplicate SCTE-35 format and add sample to TsExtractorTest

It's not clear why we're currently outputting the format in both init()
and consume() - it seems likely that this was accidentally introduced
in <unknown commit>
when we started outputting the format in consume() but didn't remove it
from init().

The SCTE-35 TsExtractorTest doesn't pass with the current code because
when it seeks back to the beginning of the file init() is not called
again so the second pass through only sees one sample (and
ExtractorAsserts checks that seeking back to 0 produces the same output
as reading the file from the beginning).

I generated the SCTE-35 sample using TSDuck's tsp command:
$ tsp --add-input-stuffing 1/10 \
   -I file testdata/src/test/assets/ts/sample.ts \
   -P pmt --service 1  --add-programinfo-id 0x43554549 --add-pid 600/0x86 \
   -P spliceinject --service 1 --files scte_35.xml --wait-first-batch \
   -P filter --negate --pid 0x1FFF \
   -O file testdata/src/test/assets/ts/sample_scte35.ts

This was adapted from the instructions in section 5.2.24.1 of the TSDuck
user manual: https://tsduck.io/download/docs/tsduck.pdf

PiperOrigin-RevId: 296217084
This commit is contained in:
ibaker 2020-02-20 16:37:29 +00:00 committed by Oliver Woodman
parent 113c418884
commit 94315ab757
8 changed files with 704 additions and 2 deletions

View File

@ -42,8 +42,6 @@ public final class SpliceInfoSectionReader implements SectionPayloadReader {
this.timestampAdjuster = timestampAdjuster;
idGenerator.generateNewId();
output = extractorOutput.track(idGenerator.getTrackId(), C.TRACK_TYPE_METADATA);
output.format(
Format.createSampleFormat(idGenerator.getFormatId(), MimeTypes.APPLICATION_SCTE35));
}
@Override

View File

@ -48,6 +48,11 @@ public final class TsExtractorTest {
ExtractorAsserts.assertBehavior(TsExtractor::new, "ts/sample.ts");
}
@Test
public void testSampleScte35() throws Exception {
ExtractorAsserts.assertBehavior(TsExtractor::new, "ts/sample_scte35.ts");
}
@Test
public void testStreamWithJunkData() throws Exception {
ExtractorAsserts.assertBehavior(

Binary file not shown.

View File

@ -0,0 +1,146 @@
seekMap:
isSeekable = true
duration = 66733
getPosition(0) = [[timeUs=0, position=0]]
getPosition(1) = [[timeUs=1, position=0]]
getPosition(33366) = [[timeUs=33366, position=25887]]
getPosition(66733) = [[timeUs=66733, position=51963]]
numberOfTracks = 4
track 256:
total output bytes = 45026
sample count = 2
format 0:
bitrate = -1
id = 1/256
containerMimeType = null
sampleMimeType = video/mpeg2
maxInputSize = -1
width = 640
height = 426
frameRate = -1.0
rotationDegrees = 0
pixelWidthHeightRatio = 1.0
channelCount = -1
sampleRate = -1
pcmEncoding = -1
encoderDelay = 0
encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
drmInitData = -
metadata = null
initializationData:
data = length 22, hash CE183139
sample 0:
time = 33366
flags = 1
data = length 20711, hash 34341E8
sample 1:
time = 66733
flags = 0
data = length 18112, hash EC44B35B
track 257:
total output bytes = 5015
sample count = 4
format 0:
bitrate = -1
id = 1/257
containerMimeType = null
sampleMimeType = audio/mpeg-L2
maxInputSize = 4096
width = -1
height = -1
frameRate = -1.0
rotationDegrees = 0
pixelWidthHeightRatio = 1.0
channelCount = 1
sampleRate = 44100
pcmEncoding = -1
encoderDelay = 0
encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = und
drmInitData = -
metadata = null
initializationData:
sample 0:
time = 22455
flags = 1
data = length 1253, hash 727FD1C6
sample 1:
time = 48577
flags = 1
data = length 1254, hash 73FB07B8
sample 2:
time = 74700
flags = 1
data = length 1254, hash 73FB07B8
sample 3:
time = 100822
flags = 1
data = length 1254, hash 73FB07B8
track 600:
total output bytes = 105
sample count = 3
format 0:
bitrate = -1
id = null
containerMimeType = null
sampleMimeType = application/x-scte35
maxInputSize = -1
width = -1
height = -1
frameRate = -1.0
rotationDegrees = 0
pixelWidthHeightRatio = 1.0
channelCount = -1
sampleRate = -1
pcmEncoding = -1
encoderDelay = 0
encoderPadding = 0
subsampleOffsetUs = -1400000
selectionFlags = 0
language = null
drmInitData = -
metadata = null
initializationData:
sample 0:
time = 33366
flags = 1
data = length 35, hash A892AAAF
sample 1:
time = 33366
flags = 1
data = length 35, hash A892AAAF
sample 2:
time = 33366
flags = 1
data = length 35, hash DFA3EF74
track 8448:
total output bytes = 0
sample count = 0
format 0:
bitrate = -1
id = 1/8448
containerMimeType = null
sampleMimeType = application/cea-608
maxInputSize = -1
width = -1
height = -1
frameRate = -1.0
rotationDegrees = 0
pixelWidthHeightRatio = 1.0
channelCount = -1
sampleRate = -1
pcmEncoding = -1
encoderDelay = 0
encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
drmInitData = -
metadata = null
initializationData:
tracksEnded = true

View File

@ -0,0 +1,146 @@
seekMap:
isSeekable = true
duration = 66733
getPosition(0) = [[timeUs=0, position=0]]
getPosition(1) = [[timeUs=1, position=0]]
getPosition(33366) = [[timeUs=33366, position=25887]]
getPosition(66733) = [[timeUs=66733, position=51963]]
numberOfTracks = 4
track 256:
total output bytes = 45026
sample count = 2
format 0:
bitrate = -1
id = 1/256
containerMimeType = null
sampleMimeType = video/mpeg2
maxInputSize = -1
width = 640
height = 426
frameRate = -1.0
rotationDegrees = 0
pixelWidthHeightRatio = 1.0
channelCount = -1
sampleRate = -1
pcmEncoding = -1
encoderDelay = 0
encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
drmInitData = -
metadata = null
initializationData:
data = length 22, hash CE183139
sample 0:
time = 55610
flags = 1
data = length 20711, hash 34341E8
sample 1:
time = 88977
flags = 0
data = length 18112, hash EC44B35B
track 257:
total output bytes = 5015
sample count = 4
format 0:
bitrate = -1
id = 1/257
containerMimeType = null
sampleMimeType = audio/mpeg-L2
maxInputSize = 4096
width = -1
height = -1
frameRate = -1.0
rotationDegrees = 0
pixelWidthHeightRatio = 1.0
channelCount = 1
sampleRate = 44100
pcmEncoding = -1
encoderDelay = 0
encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = und
drmInitData = -
metadata = null
initializationData:
sample 0:
time = 44699
flags = 1
data = length 1253, hash 727FD1C6
sample 1:
time = 70821
flags = 1
data = length 1254, hash 73FB07B8
sample 2:
time = 96944
flags = 1
data = length 1254, hash 73FB07B8
sample 3:
time = 123066
flags = 1
data = length 1254, hash 73FB07B8
track 600:
total output bytes = 105
sample count = 3
format 0:
bitrate = -1
id = null
containerMimeType = null
sampleMimeType = application/x-scte35
maxInputSize = -1
width = -1
height = -1
frameRate = -1.0
rotationDegrees = 0
pixelWidthHeightRatio = 1.0
channelCount = -1
sampleRate = -1
pcmEncoding = -1
encoderDelay = 0
encoderPadding = 0
subsampleOffsetUs = -1400000
selectionFlags = 0
language = null
drmInitData = -
metadata = null
initializationData:
sample 0:
time = 55610
flags = 1
data = length 35, hash A892AAAF
sample 1:
time = 55610
flags = 1
data = length 35, hash A892AAAF
sample 2:
time = 55610
flags = 1
data = length 35, hash DFA3EF74
track 8448:
total output bytes = 0
sample count = 0
format 0:
bitrate = -1
id = 1/8448
containerMimeType = null
sampleMimeType = application/cea-608
maxInputSize = -1
width = -1
height = -1
frameRate = -1.0
rotationDegrees = 0
pixelWidthHeightRatio = 1.0
channelCount = -1
sampleRate = -1
pcmEncoding = -1
encoderDelay = 0
encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
drmInitData = -
metadata = null
initializationData:
tracksEnded = true

View File

@ -0,0 +1,146 @@
seekMap:
isSeekable = true
duration = 66733
getPosition(0) = [[timeUs=0, position=0]]
getPosition(1) = [[timeUs=1, position=0]]
getPosition(33366) = [[timeUs=33366, position=25887]]
getPosition(66733) = [[timeUs=66733, position=51963]]
numberOfTracks = 4
track 256:
total output bytes = 45026
sample count = 2
format 0:
bitrate = -1
id = 1/256
containerMimeType = null
sampleMimeType = video/mpeg2
maxInputSize = -1
width = 640
height = 426
frameRate = -1.0
rotationDegrees = 0
pixelWidthHeightRatio = 1.0
channelCount = -1
sampleRate = -1
pcmEncoding = -1
encoderDelay = 0
encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
drmInitData = -
metadata = null
initializationData:
data = length 22, hash CE183139
sample 0:
time = 77854
flags = 1
data = length 20711, hash 34341E8
sample 1:
time = 111221
flags = 0
data = length 18112, hash EC44B35B
track 257:
total output bytes = 5015
sample count = 4
format 0:
bitrate = -1
id = 1/257
containerMimeType = null
sampleMimeType = audio/mpeg-L2
maxInputSize = 4096
width = -1
height = -1
frameRate = -1.0
rotationDegrees = 0
pixelWidthHeightRatio = 1.0
channelCount = 1
sampleRate = 44100
pcmEncoding = -1
encoderDelay = 0
encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = und
drmInitData = -
metadata = null
initializationData:
sample 0:
time = 66943
flags = 1
data = length 1253, hash 727FD1C6
sample 1:
time = 93065
flags = 1
data = length 1254, hash 73FB07B8
sample 2:
time = 119188
flags = 1
data = length 1254, hash 73FB07B8
sample 3:
time = 145310
flags = 1
data = length 1254, hash 73FB07B8
track 600:
total output bytes = 105
sample count = 3
format 0:
bitrate = -1
id = null
containerMimeType = null
sampleMimeType = application/x-scte35
maxInputSize = -1
width = -1
height = -1
frameRate = -1.0
rotationDegrees = 0
pixelWidthHeightRatio = 1.0
channelCount = -1
sampleRate = -1
pcmEncoding = -1
encoderDelay = 0
encoderPadding = 0
subsampleOffsetUs = -1400000
selectionFlags = 0
language = null
drmInitData = -
metadata = null
initializationData:
sample 0:
time = 77854
flags = 1
data = length 35, hash A892AAAF
sample 1:
time = 77854
flags = 1
data = length 35, hash A892AAAF
sample 2:
time = 77854
flags = 1
data = length 35, hash DFA3EF74
track 8448:
total output bytes = 0
sample count = 0
format 0:
bitrate = -1
id = 1/8448
containerMimeType = null
sampleMimeType = application/cea-608
maxInputSize = -1
width = -1
height = -1
frameRate = -1.0
rotationDegrees = 0
pixelWidthHeightRatio = 1.0
channelCount = -1
sampleRate = -1
pcmEncoding = -1
encoderDelay = 0
encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
drmInitData = -
metadata = null
initializationData:
tracksEnded = true

View File

@ -0,0 +1,118 @@
seekMap:
isSeekable = true
duration = 66733
getPosition(0) = [[timeUs=0, position=0]]
getPosition(1) = [[timeUs=1, position=0]]
getPosition(33366) = [[timeUs=33366, position=25887]]
getPosition(66733) = [[timeUs=66733, position=51963]]
numberOfTracks = 4
track 256:
total output bytes = 0
sample count = 0
format 0:
bitrate = -1
id = 1/256
containerMimeType = null
sampleMimeType = video/mpeg2
maxInputSize = -1
width = 640
height = 426
frameRate = -1.0
rotationDegrees = 0
pixelWidthHeightRatio = 1.0
channelCount = -1
sampleRate = -1
pcmEncoding = -1
encoderDelay = 0
encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
drmInitData = -
metadata = null
initializationData:
data = length 22, hash CE183139
track 257:
total output bytes = 2508
sample count = 2
format 0:
bitrate = -1
id = 1/257
containerMimeType = null
sampleMimeType = audio/mpeg-L2
maxInputSize = 4096
width = -1
height = -1
frameRate = -1.0
rotationDegrees = 0
pixelWidthHeightRatio = 1.0
channelCount = 1
sampleRate = 44100
pcmEncoding = -1
encoderDelay = 0
encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = und
drmInitData = -
metadata = null
initializationData:
sample 0:
time = 66733
flags = 1
data = length 1254, hash 73FB07B8
sample 1:
time = 92855
flags = 1
data = length 1254, hash 73FB07B8
track 600:
total output bytes = 0
sample count = 0
format 0:
bitrate = -1
id = null
containerMimeType = null
sampleMimeType = application/x-scte35
maxInputSize = -1
width = -1
height = -1
frameRate = -1.0
rotationDegrees = 0
pixelWidthHeightRatio = 1.0
channelCount = -1
sampleRate = -1
pcmEncoding = -1
encoderDelay = 0
encoderPadding = 0
subsampleOffsetUs = -1400000
selectionFlags = 0
language = null
drmInitData = -
metadata = null
initializationData:
track 8448:
total output bytes = 0
sample count = 0
format 0:
bitrate = -1
id = 1/8448
containerMimeType = null
sampleMimeType = application/cea-608
maxInputSize = -1
width = -1
height = -1
frameRate = -1.0
rotationDegrees = 0
pixelWidthHeightRatio = 1.0
channelCount = -1
sampleRate = -1
pcmEncoding = -1
encoderDelay = 0
encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
drmInitData = -
metadata = null
initializationData:
tracksEnded = true

View File

@ -0,0 +1,143 @@
seekMap:
isSeekable = false
duration = UNSET TIME
getPosition(0) = [[timeUs=0, position=0]]
numberOfTracks = 4
track 256:
total output bytes = 45026
sample count = 2
format 0:
bitrate = -1
id = 1/256
containerMimeType = null
sampleMimeType = video/mpeg2
maxInputSize = -1
width = 640
height = 426
frameRate = -1.0
rotationDegrees = 0
pixelWidthHeightRatio = 1.0
channelCount = -1
sampleRate = -1
pcmEncoding = -1
encoderDelay = 0
encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
drmInitData = -
metadata = null
initializationData:
data = length 22, hash CE183139
sample 0:
time = 33366
flags = 1
data = length 20711, hash 34341E8
sample 1:
time = 66733
flags = 0
data = length 18112, hash EC44B35B
track 257:
total output bytes = 5015
sample count = 4
format 0:
bitrate = -1
id = 1/257
containerMimeType = null
sampleMimeType = audio/mpeg-L2
maxInputSize = 4096
width = -1
height = -1
frameRate = -1.0
rotationDegrees = 0
pixelWidthHeightRatio = 1.0
channelCount = 1
sampleRate = 44100
pcmEncoding = -1
encoderDelay = 0
encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = und
drmInitData = -
metadata = null
initializationData:
sample 0:
time = 22455
flags = 1
data = length 1253, hash 727FD1C6
sample 1:
time = 48577
flags = 1
data = length 1254, hash 73FB07B8
sample 2:
time = 74700
flags = 1
data = length 1254, hash 73FB07B8
sample 3:
time = 100822
flags = 1
data = length 1254, hash 73FB07B8
track 600:
total output bytes = 105
sample count = 3
format 0:
bitrate = -1
id = null
containerMimeType = null
sampleMimeType = application/x-scte35
maxInputSize = -1
width = -1
height = -1
frameRate = -1.0
rotationDegrees = 0
pixelWidthHeightRatio = 1.0
channelCount = -1
sampleRate = -1
pcmEncoding = -1
encoderDelay = 0
encoderPadding = 0
subsampleOffsetUs = -1400000
selectionFlags = 0
language = null
drmInitData = -
metadata = null
initializationData:
sample 0:
time = 33366
flags = 1
data = length 35, hash A892AAAF
sample 1:
time = 33366
flags = 1
data = length 35, hash A892AAAF
sample 2:
time = 33366
flags = 1
data = length 35, hash DFA3EF74
track 8448:
total output bytes = 0
sample count = 0
format 0:
bitrate = -1
id = 1/8448
containerMimeType = null
sampleMimeType = application/cea-608
maxInputSize = -1
width = -1
height = -1
frameRate = -1.0
rotationDegrees = 0
pixelWidthHeightRatio = 1.0
channelCount = -1
sampleRate = -1
pcmEncoding = -1
encoderDelay = 0
encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
drmInitData = -
metadata = null
initializationData:
tracksEnded = true