Use the chunk id to detect the first chunk of a segment
This commit is contained in:
1 parent
155a6b6c90
commit
651e92335a
2 files changed
+14
-9
No files matched your search
@@ -49,7 +49,6 @@ class PassThroughRemuxer extends Logger implements Remuxer {
|
||||
private initPTS: TimestampOffset | null = null;
|
||||
private initTracks?: TrackSet;
|
||||
private lastEndTime: number | null = null;
|
||||
private lastChunkKey: string | null = null;
|
||||
private isVideoContiguous: boolean = false;
|
||||
private videoOnlyRemux: boolean = false;
|
||||
private decryptdata: DecryptData | null = null;
|
||||
@@ -75,7 +74,6 @@ class PassThroughRemuxer extends Logger implements Remuxer {
|
||||
|
||||
public resetTimeStamp(defaultInitPTS: TimestampOffset | null) {
|
||||
this.lastEndTime = null;
|
||||
this.lastChunkKey = null;
|
||||
const initPTS = this.initPTS;
|
||||
if (initPTS && defaultInitPTS) {
|
||||
if (
|
||||
@@ -91,7 +89,6 @@ class PassThroughRemuxer extends Logger implements Remuxer {
|
||||
public resetNextTimestamp() {
|
||||
this.isVideoContiguous = false;
|
||||
this.lastEndTime = null;
|
||||
this.lastChunkKey = null;
|
||||
}
|
||||
|
||||
public resetInitSegment(
|
||||
@@ -446,9 +443,7 @@ class PassThroughRemuxer extends Logger implements Remuxer {
|
||||
|
||||
// Every chunk of a progressive segment is remuxed with the segment's
|
||||
// timeOffset, so only the first chunk's decode time lines up with it
|
||||
const chunkKey = `${chunkMeta.level}_${chunkMeta.sn}_${chunkMeta.part}`;
|
||||
const segmentStart = chunkKey !== this.lastChunkKey;
|
||||
this.lastChunkKey = chunkKey;
|
||||
const segmentStart = chunkMeta.id === 1;
|
||||
|
||||
if (
|
||||
((accurateTimeOffset && segmentStart) || !initPTS) &&
|
||||
|
||||
@@ -108,6 +108,7 @@ describe('passthrough-remuxer', function () {
|
||||
fragmentData: Uint8Array<ArrayBuffer>,
|
||||
timeOffset: number,
|
||||
flush: boolean,
|
||||
chunkId: number,
|
||||
) {
|
||||
return remuxer.remux(
|
||||
audioTrack(),
|
||||
@@ -118,7 +119,16 @@ describe('passthrough-remuxer', function () {
|
||||
true,
|
||||
flush,
|
||||
PlaylistLevelType.MAIN,
|
||||
new ChunkMetadata(0, 0, 0, fragmentData.byteLength, -1, true, 4, false),
|
||||
new ChunkMetadata(
|
||||
0,
|
||||
0,
|
||||
chunkId,
|
||||
fragmentData.byteLength,
|
||||
-1,
|
||||
true,
|
||||
4,
|
||||
false,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -441,8 +451,8 @@ describe('passthrough-remuxer', function () {
|
||||
const firstChunk = mp4FragmentAt(0, [sample(180000, 4, 0)]);
|
||||
const secondChunk = mp4FragmentAt(180000, [sample(180000, 4, 0)]);
|
||||
|
||||
const first = remuxProgressiveChunk(firstChunk, 0, false);
|
||||
const second = remuxProgressiveChunk(secondChunk, 0, true);
|
||||
const first = remuxProgressiveChunk(firstChunk, 0, false, 1);
|
||||
const second = remuxProgressiveChunk(secondChunk, 0, true, 2);
|
||||
|
||||
expect(first.video, 'first chunk video track').to.exist;
|
||||
expect(first.video!.startDTS, 'first chunk startDTS').to.equal(0);
|
||||
|
||||
Reference in new issue
Block a user