Skip to content

🎥 Make videos programmatically with React

stts atom

Jonny Burger0a5d69c5267d
diff --git a/packages/media-parser/src/create/iso-base-media/create-stts.ts b/packages/media-parser/src/create/iso-base-media/create-stts.ts
new file mode 100644
index 0000000000..28d4bd1a17
--- /dev/null
+++ b/packages/media-parser/src/create/iso-base-media/create-stts.ts
@@ -0,0 +1,54 @@
+import {combineUint8Arrays} from '../../boxes/webm/make-header';
+import type {SamplePosition} from '../../get-sample-positions';
+import {
+ addSize,
+ numberTo32BitUIntOrInt,
+ stringsToUint8Array,
+} from './primitives';
+
+type Entry = {
+ sampleCount: number;
+ sampleOffset: number;
+};
+
+const makeEntry = (entry: Entry) => {
+ return combineUint8Arrays([
+ numberTo32BitUIntOrInt(entry.sampleCount),
+ numberTo32BitUIntOrInt(entry.sampleOffset),
+ ]);
+};
+
+export const createSttsAtom = (samplePositions: SamplePosition[]) => {
+ let lastDuration: null | number = null;
+ const durations = samplePositions.map(({duration}) => duration);
+
+ const entries: Entry[] = [];
+
+ for (const duration of durations) {
+ if (duration === lastDuration) {
+ entries[entries.length - 1].sampleCount++;
+ } else {
+ entries.push({
+ sampleCount: 1,
+ sampleOffset: duration,
+ });
+ }
+
+ lastDuration = duration;
+ }
+
+ return addSize(
+ combineUint8Arrays([
+ // type
+ stringsToUint8Array('stts'),
+ // version
+ new Uint8Array([0]),
+ // flags
+ new Uint8Array([0, 0, 0]),
+ // entry count
+ numberTo32BitUIntOrInt(entries.length),
+ // entries
+ ...entries.map((e) => makeEntry(e)),
+ ]),
+ );
+};
diff --git a/packages/media-parser/src/create/iso-base-media/example-stts.ts b/packages/media-parser/src/create/iso-base-media/example-stts.ts
new file mode 100644
index 0000000000..5dcfbd47d2
--- /dev/null
+++ b/packages/media-parser/src/create/iso-base-media/example-stts.ts
@@ -0,0 +1,1524 @@
+import type {SamplePosition} from '../../get-sample-positions';
+
+export const exampleSamplePositions: SamplePosition[] = [
+ {
+ offset: 18371,
+ size: 846,
+ isKeyframe: true,
+ dts: 0,
+ cts: 0,
+ duration: 1024,
+ },
+ {
+ offset: 19217,
+ size: 846,
+ isKeyframe: true,
+ dts: 1024,
+ cts: 1024,
+ duration: 1024,
+ },
+ {
+ offset: 20933,
+ size: 847,
+ isKeyframe: true,
+ dts: 2048,
+ cts: 2048,
+ duration: 1024,
+ },
+ {
+ offset: 21780,
+ size: 846,
+ isKeyframe: true,
+ dts: 3072,
+ cts: 3072,
+ duration: 1024,
+ },
+ {
+ offset: 23364,
+ size: 846,
+ isKeyframe: true,
+ dts: 4096,
+ cts: 4096,
+ duration: 1024,
+ },
+ {
+ offset: 27280,
+ size: 847,
+ isKeyframe: true,
+ dts: 5120,
+ cts: 5120,
+ duration: 1024,
+ },
+ {
+ offset: 28127,
+ size: 846,
+ isKeyframe: true,
+ dts: 6144,
+ cts: 6144,
+ duration: 1024,
+ },
+ {
+ offset: 29767,
+ size: 846,
+ isKeyframe: true,
+ dts: 7168,
+ cts: 7168,
+ duration: 1024,
+ },
+ {
+ offset: 33649,
+ size: 847,
+ isKeyframe: true,
+ dts: 8192,
+ cts: 8192,
+ duration: 1024,
+ },
+ {
+ offset: 34496,
+ size: 846,
+ isKeyframe: true,
+ dts: 9216,
+ cts: 9216,
+ duration: 1024,
+ },
+ {
+ offset: 36295,
+ size: 846,
+ isKeyframe: true,
+ dts: 10240,
+ cts: 10240,
+ duration: 1024,
+ },
+ {
+ offset: 37864,
+ size: 847,
+ isKeyframe: true,
+ dts: 11264,
+ cts: 11264,
+ duration: 1024,
+ },
+ {
+ offset: 38711,
+ size: 846,
+ isKeyframe: true,
+ dts: 12288,
+ cts: 12288,
+ duration: 1024,
+ },
+ {
+ offset: 43054,
+ size: 846,
+ isKeyframe: true,
+ dts: 13312,
+ cts: 13312,
+ duration: 1024,
+ },
+ {
+ offset: 43900,
+ size: 847,
+ isKeyframe: true,
+ dts: 14336,
+ cts: 14336,
+ duration: 1024,
+ },
+ {
+ offset: 45632,
+ size: 846,
+ isKeyframe: true,
+ dts: 15360,
+ cts: 15360,
+ duration: 1024,
+ },
+ {
+ offset: 49264,
+ size: 846,
+ isKeyframe: true,
+ dts: 16384,
+ cts: 16384,
+ duration: 1024,
+ },
+ {
+ offset: 50110,
+ size: 847,
+ isKeyframe: true,
+ dts: 17408,
+ cts: 17408,
+ duration: 1024,
+ },
+ {
+ offset: 56542,
+ size: 846,
+ isKeyframe: true,
+ dts: 18432,
+ cts: 18432,
+ duration: 1024,
+ },
+ {
+ offset: 60340,
+ size: 846,
+ isKeyframe: true,
+ dts: 19456,
+ cts: 19456,
+ duration: 1024,
+ },
+ {
+ offset: 61186,
+ size: 847,
+ isKeyframe: true,
+ dts: 20480,
+ cts: 20480,
+ duration: 1024,
+ },
+ {
+ offset: 63471,
+ size: 846,
+ isKeyframe: true,
+ dts: 21504,
+ cts: 21504,
+ duration: 1024,
+ },
+ {
+ offset: 66884,
+ size: 846,
+ isKeyframe: true,
+ dts: 22528,
+ cts: 22528,
+ duration: 1024,
+ },
+ {
+ offset: 67730,
+ size: 847,
+ isKeyframe: true,
+ dts: 23552,
+ cts: 23552,
+ duration: 1024,
+ },
+ {
+ offset: 72064,
+ size: 846,
+ isKeyframe: true,
+ dts: 24576,
+ cts: 24576,
+ duration: 1024,
+ },
+ {
+ offset: 75599,
+ size: 846,
+ isKeyframe: true,
+ dts: 25600,
+ cts: 25600,
+ duration: 1024,
+ },
+ {
+ offset: 76445,
+ size: 847,
+ isKeyframe: true,
+ dts: 26624,
+ cts: 26624,
+ duration: 1024,
+ },
+ {
+ offset: 79071,
+ size: 846,
+ isKeyframe: true,
+ dts: 27648,
+ cts: 27648,
+ duration: 1024,
+ },
+ {
+ offset: 79917,
+ size: 846,
+ isKeyframe: true,
+ dts: 28672,
+ cts: 28672,
+ duration: 1024,
+ },
+ {
+ offset: 94703,
+ size: 847,
+ isKeyframe: true,
+ dts: 29696,
+ cts: 29696,
+ duration: 1024,
+ },
+ {
+ offset: 99422,
+ size: 846,
+ isKeyframe: true,
+ dts: 30720,
+ cts: 30720,
+ duration: 1024,
+ },
+ {
+ offset: 100268,
+ size: 846,
+ isKeyframe: true,
+ dts: 31744,
+ cts: 31744,
+ duration: 1024,
+ },
+ {
+ offset: 102598,
+ size: 846,
+ isKeyframe: true,
+ dts: 32768,
+ cts: 32768,
+ duration: 1024,
+ },
+ {
+ offset: 107431,
+ size: 846,
+ isKeyframe: true,
+ dts: 33792,
+ cts: 33792,
+ duration: 1024,
+ },
+ {
+ offset: 108277,
+ size: 847,
+ isKeyframe: true,
+ dts: 34816,
+ cts: 34816,
+ duration: 1024,
+ },
+ {
+ offset: 110913,
+ size: 846,
+ isKeyframe: true,
+ dts: 35840,
+ cts: 35840,
+ duration: 1024,
+ },
+ {
+ offset: 115631,
+ size: 846,
+ isKeyframe: true,
+ dts: 36864,
+ cts: 36864,
+ duration: 1024,
+ },
+ {
+ offset: 116477,
+ size: 847,
+ isKeyframe: true,
+ dts: 37888,
+ cts: 37888,
+ duration: 1024,
+ },
+ {
+ offset: 120845,
+ size: 846,
+ isKeyframe: true,
+ dts: 38912,
+ cts: 38912,
+ duration: 1024,
+ },
+ {
+ offset: 121691,
+ size: 846,
+ isKeyframe: true,
+ dts: 39936,
+ cts: 39936,
+ duration: 1024,
+ },
+ {
+ offset: 126236,
+ size: 847,
+ isKeyframe: true,
+ dts: 40960,
+ cts: 40960,
+ duration: 1024,
+ },
+ {
+ offset: 130895,
+ size: 846,
+ isKeyframe: true,
+ dts: 41984,
+ cts: 41984,
+ duration: 1024,
+ },
+ {
+ offset: 131741,
+ size: 846,
+ isKeyframe: true,
+ dts: 43008,
+ cts: 43008,
+ duration: 1024,
+ },
+ {
+ offset: 134047,
+ size: 847,
+ isKeyframe: true,
+ dts: 44032,
+ cts: 44032,
+ duration: 1024,
+ },
+ {
+ offset: 139397,
+ size: 846,
+ isKeyframe: true,
+ dts: 45056,
+ cts: 45056,
+ duration: 1024,
+ },
+ {
+ offset: 140243,
+ size: 846,
+ isKeyframe: true,
+ dts: 46080,
+ cts: 46080,
+ duration: 1024,
+ },
+ {
+ offset: 142927,
+ size: 847,
+ isKeyframe: true,
+ dts: 47104,
+ cts: 47104,
+ duration: 1024,
+ },
+ {
+ offset: 145038,
+ size: 846,
+ isKeyframe: true,
+ dts: 48128,
+ cts: 48128,
+ duration: 1024,
+ },
+ {
+ offset: 145884,
+ size: 846,
+ isKeyframe: true,
+ dts: 49152,
+ cts: 49152,
+ duration: 1024,
+ },
+ {
+ offset: 147930,
+ size: 847,
+ isKeyframe: true,
+ dts: 50176,
+ cts: 50176,
+ duration: 1024,
+ },
+ {
+ offset: 152173,
+ size: 846,
+ isKeyframe: true,
+ dts: 51200,
+ cts: 51200,
+ duration: 1024,
+ },
+ {
+ offset: 153019,
+ size: 846,
+ isKeyframe: true,
+ dts: 52224,
+ cts: 52224,
+ duration: 1024,
+ },
+ {
+ offset: 156195,
+ size: 847,
+ isKeyframe: true,
+ dts: 53248,
+ cts: 53248,
+ duration: 1024,
+ },
+ {
+ offset: 157042,
+ size: 846,
+ isKeyframe: true,
+ dts: 54272,
+ cts: 54272,
+ duration: 1024,
+ },
+ {
+ offset: 158982,
+ size: 846,
+ isKeyframe: true,
+ dts: 55296,
+ cts: 55296,
+ duration: 1024,
+ },
+ {
+ offset: 161027,
+ size: 847,
+ isKeyframe: true,
+ dts: 56320,
+ cts: 56320,
+ duration: 1024,
+ },
+ {
+ offset: 161874,
+ size: 846,
+ isKeyframe: true,
+ dts: 57344,
+ cts: 57344,
+ duration: 1024,
+ },
+ {
+ offset: 164584,
+ size: 846,
+ isKeyframe: true,
+ dts: 58368,
+ cts: 58368,
+ duration: 1024,
+ },
+ {
+ offset: 166334,
+ size: 847,
+ isKeyframe: true,
+ dts: 59392,
+ cts: 59392,
+ duration: 1024,
+ },
+ {
+ offset: 167181,
+ size: 846,
+ isKeyframe: true,
+ dts: 60416,
+ cts: 60416,
+ duration: 1024,
+ },
+ {
+ offset: 183644,
+ size: 846,
+ isKeyframe: true,
+ dts: 61440,
+ cts: 61440,
+ duration: 1024,
+ },
+ {
+ offset: 189240,
+ size: 847,
+ isKeyframe: true,
+ dts: 62464,
+ cts: 62464,
+ duration: 1024,
+ },
+ {
+ offset: 190087,
+ size: 846,
+ isKeyframe: true,
+ dts: 63488,
+ cts: 63488,
+ duration: 1024,
+ },
+ {
+ offset: 192039,
+ size: 846,
+ isKeyframe: true,
+ dts: 64512,
+ cts: 64512,
+ duration: 1024,
+ },
+ {
+ offset: 192885,
+ size: 846,
+ isKeyframe: true,
+ dts: 65536,
+ cts: 65536,
+ duration: 1024,
+ },
+ {
+ offset: 196197,
+ size: 846,
+ isKeyframe: true,
+ dts: 66560,
+ cts: 66560,
+ duration: 1024,
+ },
+ {
+ offset: 200022,
+ size: 847,
+ isKeyframe: true,
+ dts: 67584,
+ cts: 67584,
+ duration: 1024,
+ },
+ {
+ offset: 200869,
+ size: 846,
+ isKeyframe: true,
+ dts: 68608,
+ cts: 68608,
+ duration: 1024,
+ },
+ {
+ offset: 207325,
+ size: 846,
+ isKeyframe: true,
+ dts: 69632,
+ cts: 69632,
+ duration: 1024,
+ },
+ {
+ offset: 210200,
+ size: 847,
+ isKeyframe: true,
+ dts: 70656,
+ cts: 70656,
+ duration: 1024,
+ },
+ {
+ offset: 211047,
+ size: 846,
+ isKeyframe: true,
+ dts: 71680,
+ cts: 71680,
+ duration: 1024,
+ },
+ {
+ offset: 212650,
+ size: 846,
+ isKeyframe: true,
+ dts: 72704,
+ cts: 72704,
+ duration: 1024,
+ },
+ {
+ offset: 214340,
+ size: 847,
+ isKeyframe: true,
+ dts: 73728,
+ cts: 73728,
+ duration: 1024,
+ },
+ {
+ offset: 215187,
+ size: 846,
+ isKeyframe: true,
+ dts: 74752,
+ cts: 74752,
+ duration: 1024,
+ },
+ {
+ offset: 221199,
+ size: 846,
+ isKeyframe: true,
+ dts: 75776,
+ cts: 75776,
+ duration: 1024,
+ },
+ {
+ offset: 223441,
+ size: 847,
+ isKeyframe: true,
+ dts: 76800,
+ cts: 76800,
+ duration: 1024,
+ },
+ {
+ offset: 224288,
+ size: 846,
+ isKeyframe: true,
+ dts: 77824,
+ cts: 77824,
+ duration: 1024,
+ },
+ {
+ offset: 225951,
+ size: 846,
+ isKeyframe: true,
+ dts: 78848,
+ cts: 78848,
+ duration: 1024,
+ },
+ {
+ offset: 226797,
+ size: 847,
+ isKeyframe: true,
+ dts: 79872,
+ cts: 79872,
+ duration: 1024,
+ },
+ {
+ offset: 228784,
+ size: 846,
+ isKeyframe: true,
+ dts: 80896,
+ cts: 80896,
+ duration: 1024,
+ },
+ {
+ offset: 232053,
+ size: 846,
+ isKeyframe: true,
+ dts: 81920,
+ cts: 81920,
+ duration: 1024,
+ },
+ {
+ offset: 232899,
+ size: 847,
+ isKeyframe: true,
+ dts: 82944,
+ cts: 82944,
+ duration: 1024,
+ },
+ {
+ offset: 236103,
+ size: 846,
+ isKeyframe: true,
+ dts: 83968,
+ cts: 83968,
+ duration: 1024,
+ },
+ {
+ offset: 240130,
+ size: 846,
+ isKeyframe: true,
+ dts: 84992,
+ cts: 84992,
+ duration: 1024,
+ },
+ {
+ offset: 240976,
+ size: 847,
+ isKeyframe: true,
+ dts: 86016,
+ cts: 86016,
+ duration: 1024,
+ },
+ {
+ offset: 242911,
+ size: 846,
+ isKeyframe: true,
+ dts: 87040,
+ cts: 87040,
+ duration: 1024,
+ },
+ {
+ offset: 244697,
+ size: 846,
+ isKeyframe: true,
+ dts: 88064,
+ cts: 88064,
+ duration: 1024,
+ },
+ {
+ offset: 245543,
+ size: 847,
+ isKeyframe: true,
+ dts: 89088,
+ cts: 89088,
+ duration: 1024,
+ },
+ {
+ offset: 248287,
+ size: 846,
+ isKeyframe: true,
+ dts: 90112,
+ cts: 90112,
+ duration: 1024,
+ },
+ {
+ offset: 249133,
+ size: 846,
+ isKeyframe: true,
+ dts: 91136,
+ cts: 91136,
+ duration: 1024,
+ },
+ {
+ offset: 250975,
+ size: 847,
+ isKeyframe: true,
+ dts: 92160,
+ cts: 92160,
+ duration: 1024,
+ },
+ {
+ offset: 271194,
+ size: 846,
+ isKeyframe: true,
+ dts: 93184,
+ cts: 93184,
+ duration: 1024,
+ },
+ {
+ offset: 272040,
+ size: 846,
+ isKeyframe: true,
+ dts: 94208,
+ cts: 94208,
+ duration: 1024,
+ },
+ {
+ offset: 275759,
+ size: 847,
+ isKeyframe: true,
+ dts: 95232,
+ cts: 95232,
+ duration: 1024,
+ },
+ {
+ offset: 277600,
+ size: 846,
+ isKeyframe: true,
+ dts: 96256,
+ cts: 96256,
+ duration: 1024,
+ },
+ {
+ offset: 278446,
+ size: 846,
+ isKeyframe: true,
+ dts: 97280,
+ cts: 97280,
+ duration: 1024,
+ },
+ {
+ offset: 281459,
+ size: 846,
+ isKeyframe: true,
+ dts: 98304,
+ cts: 98304,
+ duration: 1024,
+ },
+ {
+ offset: 284684,
+ size: 847,
+ isKeyframe: true,
+ dts: 99328,
+ cts: 99328,
+ duration: 1024,
+ },
+ {
+ offset: 285531,
+ size: 846,
+ isKeyframe: true,
+ dts: 100352,
+ cts: 100352,
+ duration: 1024,
+ },
+ {
+ offset: 287254,
+ size: 846,
+ isKeyframe: true,
+ dts: 101376,
+ cts: 101376,
+ duration: 1024,
+ },
+ {
+ offset: 288768,
+ size: 847,
+ isKeyframe: true,
+ dts: 102400,
+ cts: 102400,
+ duration: 1024,
+ },
+ {
+ offset: 289615,
+ size: 846,
+ isKeyframe: true,
+ dts: 103424,
+ cts: 103424,
+ duration: 1024,
+ },
+ {
+ offset: 291982,
+ size: 846,
+ isKeyframe: true,
+ dts: 104448,
+ cts: 104448,
+ duration: 1024,
+ },
+ {
+ offset: 292828,
+ size: 847,
+ isKeyframe: true,
+ dts: 105472,
+ cts: 105472,
+ duration: 1024,
+ },
+ {
+ offset: 295622,
+ size: 846,
+ isKeyframe: true,
+ dts: 106496,
+ cts: 106496,
+ duration: 1024,
+ },
+ {
+ offset: 297347,
+ size: 846,
+ isKeyframe: true,
+ dts: 107520,
+ cts: 107520,
+ duration: 1024,
+ },
+ {
+ offset: 298193,
+ size: 847,
+ isKeyframe: true,
+ dts: 108544,
+ cts: 108544,
+ duration: 1024,
+ },
+ {
+ offset: 299580,
+ size: 846,
+ isKeyframe: true,
+ dts: 109568,
+ cts: 109568,
+ duration: 1024,
+ },
+ {
+ offset: 301055,
+ size: 846,
+ isKeyframe: true,
+ dts: 110592,
+ cts: 110592,
+ duration: 1024,
+ },
+ {
+ offset: 301901,
+ size: 847,
+ isKeyframe: true,
+ dts: 111616,
+ cts: 111616,
+ duration: 1024,
+ },
+ {
+ offset: 304185,
+ size: 846,
+ isKeyframe: true,
+ dts: 112640,
+ cts: 112640,
+ duration: 1024,
+ },
+ {
+ offset: 305913,
+ size: 846,
+ isKeyframe: true,
+ dts: 113664,
+ cts: 113664,
+ duration: 1024,
+ },
+ {
+ offset: 306759,
+ size: 847,
+ isKeyframe: true,
+ dts: 114688,
+ cts: 114688,
+ duration: 1024,
+ },
+ {
+ offset: 308162,
+ size: 846,
+ isKeyframe: true,
+ dts: 115712,
+ cts: 115712,
+ duration: 1024,
+ },
+ {
+ offset: 309008,
+ size: 846,
+ isKeyframe: true,
+ dts: 116736,
+ cts: 116736,
+ duration: 1024,
+ },
+ {
+ offset: 310387,
+ size: 847,
+ isKeyframe: true,
+ dts: 117760,
+ cts: 117760,
+ duration: 1024,
+ },
+ {
+ offset: 312072,
+ size: 846,
+ isKeyframe: true,
+ dts: 118784,
+ cts: 118784,
+ duration: 1024,
+ },
+ {
+ offset: 312918,
+ size: 846,
+ isKeyframe: true,
+ dts: 119808,
+ cts: 119808,
+ duration: 1024,
+ },
+ {
+ offset: 314620,
+ size: 847,
+ isKeyframe: true,
+ dts: 120832,
+ cts: 120832,
+ duration: 1024,
+ },
+ {
+ offset: 315933,
+ size: 846,
+ isKeyframe: true,
+ dts: 121856,
+ cts: 121856,
+ duration: 1024,
+ },
+ {
+ offset: 316779,
+ size: 846,
+ isKeyframe: true,
+ dts: 122880,
+ cts: 122880,
+ duration: 1024,
+ },
+ {
+ offset: 318138,
+ size: 847,
+ isKeyframe: true,
+ dts: 123904,
+ cts: 123904,
+ duration: 1024,
+ },
+ {
+ offset: 338535,
+ size: 846,
+ isKeyframe: true,
+ dts: 124928,
+ cts: 124928,
+ duration: 1024,
+ },
+ {
+ offset: 339381,
+ size: 846,
+ isKeyframe: true,
+ dts: 125952,
+ cts: 125952,
+ duration: 1024,
+ },
+ {
+ offset: 342117,
+ size: 847,
+ isKeyframe: true,
+ dts: 126976,
+ cts: 126976,
+ duration: 1024,
+ },
+ {
+ offset: 343840,
+ size: 846,
+ isKeyframe: true,
+ dts: 128000,
+ cts: 128000,
+ duration: 1024,
+ },
+ {
+ offset: 344686,
+ size: 846,
+ isKeyframe: true,
+ dts: 129024,
+ cts: 129024,
+ duration: 1024,
+ },
+ {
+ offset: 346024,
+ size: 846,
+ isKeyframe: true,
+ dts: 130048,
+ cts: 130048,
+ duration: 1024,
+ },
+ {
+ offset: 346870,
+ size: 847,
+ isKeyframe: true,
+ dts: 131072,
+ cts: 131072,
+ duration: 1024,
+ },
+ {
+ offset: 348310,
+ size: 846,
+ isKeyframe: true,
+ dts: 132096,
+ cts: 132096,
+ duration: 1024,
+ },
+ {
+ offset: 350813,
+ size: 846,
+ isKeyframe: true,
+ dts: 133120,
+ cts: 133120,
+ duration: 1024,
+ },
+ {
+ offset: 351659,
+ size: 847,
+ isKeyframe: true,
+ dts: 134144,
+ cts: 134144,
+ duration: 1024,
+ },
+ {
+ offset: 353431,
+ size: 846,
+ isKeyframe: true,
+ dts: 135168,
+ cts: 135168,
+ duration: 1024,
+ },
+ {
+ offset: 354917,
+ size: 846,
+ isKeyframe: true,
+ dts: 136192,
+ cts: 136192,
+ duration: 1024,
+ },
+ {
+ offset: 355763,
+ size: 847,
+ isKeyframe: true,
+ dts: 137216,
+ cts: 137216,
+ duration: 1024,
+ },
+ {
+ offset: 357394,
+ size: 846,
+ isKeyframe: true,
+ dts: 138240,
+ cts: 138240,
+ duration: 1024,
+ },
+ {
+ offset: 359595,
+ size: 846,
+ isKeyframe: true,
+ dts: 139264,
+ cts: 139264,
+ duration: 1024,
+ },
+ {
+ offset: 360441,
+ size: 847,
+ isKeyframe: true,
+ dts: 140288,
+ cts: 140288,
+ duration: 1024,
+ },
+ {
+ offset: 362912,
+ size: 846,
+ isKeyframe: true,
+ dts: 141312,
+ cts: 141312,
+ duration: 1024,
+ },
+ {
+ offset: 363758,
+ size: 846,
+ isKeyframe: true,
+ dts: 142336,
+ cts: 142336,
+ duration: 1024,
+ },
+ {
+ offset: 365473,
+ size: 847,
+ isKeyframe: true,
+ dts: 143360,
+ cts: 143360,
+ duration: 1024,
+ },
+ {
+ offset: 367717,
+ size: 846,
+ isKeyframe: true,
+ dts: 144384,
+ cts: 144384,
+ duration: 1024,
+ },
+ {
+ offset: 368563,
+ size: 846,
+ isKeyframe: true,
+ dts: 145408,
+ cts: 145408,
+ duration: 1024,
+ },
+ {
+ offset: 370781,
+ size: 847,
+ isKeyframe: true,
+ dts: 146432,
+ cts: 146432,
+ duration: 1024,
+ },
+ {
+ offset: 373058,
+ size: 846,
+ isKeyframe: true,
+ dts: 147456,
+ cts: 147456,
+ duration: 1024,
+ },
+ {
+ offset: 373904,
+ size: 846,
+ isKeyframe: true,
+ dts: 148480,
+ cts: 148480,
+ duration: 1024,
+ },
+ {
+ offset: 376131,
+ size: 847,
+ isKeyframe: true,
+ dts: 149504,
+ cts: 149504,
+ duration: 1024,
+ },
+ {
+ offset: 377699,
+ size: 846,
+ isKeyframe: true,
+ dts: 150528,
+ cts: 150528,
+ duration: 1024,
+ },
+ {
+ offset: 378545,
+ size: 846,
+ isKeyframe: true,
+ dts: 151552,
+ cts: 151552,
+ duration: 1024,
+ },
+ {
+ offset: 380447,
+ size: 847,
+ isKeyframe: true,
+ dts: 152576,
+ cts: 152576,
+ duration: 1024,
+ },
+ {
+ offset: 382454,
+ size: 846,
+ isKeyframe: true,
+ dts: 153600,
+ cts: 153600,
+ duration: 1024,
+ },
+ {
+ offset: 383300,
+ size: 846,
+ isKeyframe: true,
+ dts: 154624,
+ cts: 154624,
+ duration: 1024,
+ },
+ {
+ offset: 385086,
+ size: 847,
+ isKeyframe: true,
+ dts: 155648,
+ cts: 155648,
+ duration: 1024,
+ },
+ {
+ offset: 385933,
+ size: 846,
+ isKeyframe: true,
+ dts: 156672,
+ cts: 156672,
+ duration: 1024,
+ },
+ {
+ offset: 406737,
+ size: 846,
+ isKeyframe: true,
+ dts: 157696,
+ cts: 157696,
+ duration: 1024,
+ },
+ {
+ offset: 410031,
+ size: 847,
+ isKeyframe: true,
+ dts: 158720,
+ cts: 158720,
+ duration: 1024,
+ },
+ {
+ offset: 410878,
+ size: 846,
+ isKeyframe: true,
+ dts: 159744,
+ cts: 159744,
+ duration: 1024,
+ },
+ {
+ offset: 412750,
+ size: 846,
+ isKeyframe: true,
+ dts: 160768,
+ cts: 160768,
+ duration: 1024,
+ },
+ {
+ offset: 414147,
+ size: 846,
+ isKeyframe: true,
+ dts: 161792,
+ cts: 161792,
+ duration: 1024,
+ },
+ {
+ offset: 414993,
+ size: 847,
+ isKeyframe: true,
+ dts: 162816,
+ cts: 162816,
+ duration: 1024,
+ },
+ {
+ offset: 416240,
+ size: 846,
+ isKeyframe: true,
+ dts: 163840,
+ cts: 163840,
+ duration: 1024,
+ },
+ {
+ offset: 418817,
+ size: 846,
+ isKeyframe: true,
+ dts: 164864,
+ cts: 164864,
+ duration: 1024,
+ },
+ {
+ offset: 419663,
+ size: 847,
+ isKeyframe: true,
+ dts: 165888,
+ cts: 165888,
+ duration: 1024,
+ },
+ {
+ offset: 420896,
+ size: 846,
+ isKeyframe: true,
+ dts: 166912,
+ cts: 166912,
+ duration: 1024,
+ },
+ {
+ offset: 421742,
+ size: 846,
+ isKeyframe: true,
+ dts: 167936,
+ cts: 167936,
+ duration: 1024,
+ },
+ {
+ offset: 423753,
+ size: 847,
+ isKeyframe: true,
+ dts: 168960,
+ cts: 168960,
+ duration: 1024,
+ },
+ {
+ offset: 425005,
+ size: 846,
+ isKeyframe: true,
+ dts: 169984,
+ cts: 169984,
+ duration: 1024,
+ },
+ {
+ offset: 425851,
+ size: 846,
+ isKeyframe: true,
+ dts: 171008,
+ cts: 171008,
+ duration: 1024,
+ },
+ {
+ offset: 427683,
+ size: 847,
+ isKeyframe: true,
+ dts: 172032,
+ cts: 172032,
+ duration: 1024,
+ },
+ {
+ offset: 429017,
+ size: 846,
+ isKeyframe: true,
+ dts: 173056,
+ cts: 173056,
+ duration: 1024,
+ },
+ {
+ offset: 429863,
+ size: 846,
+ isKeyframe: true,
+ dts: 174080,
+ cts: 174080,
+ duration: 1024,
+ },
+ {
+ offset: 431129,
+ size: 847,
+ isKeyframe: true,
+ dts: 175104,
+ cts: 175104,
+ duration: 1024,
+ },
+ {
+ offset: 432868,
+ size: 846,
+ isKeyframe: true,
+ dts: 176128,
+ cts: 176128,
+ duration: 1024,
+ },
+ {
+ offset: 433714,
+ size: 846,
+ isKeyframe: true,
+ dts: 177152,
+ cts: 177152,
+ duration: 1024,
+ },
+ {
+ offset: 434938,
+ size: 847,
+ isKeyframe: true,
+ dts: 178176,
+ cts: 178176,
+ duration: 1024,
+ },
+ {
+ offset: 436570,
+ size: 846,
+ isKeyframe: true,
+ dts: 179200,
+ cts: 179200,
+ duration: 1024,
+ },
+ {
+ offset: 437416,
+ size: 846,
+ isKeyframe: true,
+ dts: 180224,
+ cts: 180224,
+ duration: 1024,
+ },
+ {
+ offset: 438580,
+ size: 847,
+ isKeyframe: true,
+ dts: 181248,
+ cts: 181248,
+ duration: 1024,
+ },
+ {
+ offset: 439427,
+ size: 846,
+ isKeyframe: true,
+ dts: 182272,
+ cts: 182272,
+ duration: 1024,
+ },
+ {
+ offset: 440902,
+ size: 846,
+ isKeyframe: true,
+ dts: 183296,
+ cts: 183296,
+ duration: 1024,
+ },
+ {
+ offset: 442049,
+ size: 847,
+ isKeyframe: true,
+ dts: 184320,
+ cts: 184320,
+ duration: 1024,
+ },
+ {
+ offset: 442896,
+ size: 846,
+ isKeyframe: true,
+ dts: 185344,
+ cts: 185344,
+ duration: 1024,
+ },
+ {
+ offset: 444965,
+ size: 846,
+ isKeyframe: true,
+ dts: 186368,
+ cts: 186368,
+ duration: 1024,
+ },
+ {
+ offset: 446371,
+ size: 847,
+ isKeyframe: true,
+ dts: 187392,
+ cts: 187392,
+ duration: 1024,
+ },
+ {
+ offset: 447218,
+ size: 846,
+ isKeyframe: true,
+ dts: 188416,
+ cts: 188416,
+ duration: 1024,
+ },
+ {
+ offset: 448064,
+ size: 846,
+ isKeyframe: true,
+ dts: 189440,
+ cts: 189440,
+ duration: 1024,
+ },
+ {
+ offset: 448910,
+ size: 847,
+ isKeyframe: true,
+ dts: 190464,
+ cts: 190464,
+ duration: 1024,
+ },
+ {
+ offset: 449757,
+ size: 846,
+ isKeyframe: true,
+ dts: 191488,
+ cts: 191488,
+ duration: 1024,
+ },
+ {
+ offset: 450603,
+ size: 846,
+ isKeyframe: true,
+ dts: 192512,
+ cts: 192512,
+ duration: 1024,
+ },
+ {
+ offset: 451449,
+ size: 847,
+ isKeyframe: true,
+ dts: 193536,
+ cts: 193536,
+ duration: 1024,
+ },
+];
diff --git a/packages/media-parser/src/get-sample-positions.ts b/packages/media-parser/src/get-sample-positions.ts
index cd11753a1b..121aa9cbee 100644
--- a/packages/media-parser/src/get-sample-positions.ts
+++ b/packages/media-parser/src/get-sample-positions.ts
@@ -89,5 +89,6 @@ export const getSamplePositions = ({
}
}
+ console.log(samples);
return samples;
};
diff --git a/packages/media-parser/src/test/stts.test.ts b/packages/media-parser/src/test/stts.test.ts
new file mode 100644
index 0000000000..5219eac5f5
--- /dev/null
+++ b/packages/media-parser/src/test/stts.test.ts
@@ -0,0 +1,12 @@
+import {expect, test} from 'bun:test';
+import {createSttsAtom} from '../create/iso-base-media/create-stts';
+import {exampleSamplePositions} from '../create/iso-base-media/example-stts';
+
+const reference = new Uint8Array([
+ 0x00, 0x00, 0x00, 0x18, 0x73, 0x74, 0x74, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xbe, 0x00, 0x00, 0x04, 0x00,
+]);
+
+test('stts', () => {
+ return expect(createSttsAtom(exampleSamplePositions)).toEqual(reference);
+});