🎥 Make videos programmatically with React
start supporting getting sample aspect ratio
Jonny Burger02ba3cc461fd
diff --git a/packages/media-parser/dar.json b/packages/media-parser/dar.jsonnew file mode 100644index 0000000000..2d9bc1dce7--- /dev/null+++ b/packages/media-parser/dar.json@@ -0,0 +1,2556 @@+[+ {+ "type": "ftyp-box",+ "majorBrand": "isom",+ "minorVersion": 512,+ "compatibleBrands": [+ "isom",+ "iso2",+ "avc1",+ "mp41"+ ],+ "offset": 0,+ "boxSize": 32+ },+ {+ "offset": 32,+ "boxSize": 7433,+ "type": "moov-box",+ "children": [+ {+ "creationTime": null,+ "modificationTime": null,+ "timeScale": 1000,+ "durationInUnits": 5725,+ "durationInSeconds": 5.725,+ "rate": 1,+ "volume": 1,+ "matrix": [+ 1,+ 0,+ 0,+ 0,+ 1,+ 0,+ 0,+ 0,+ 1+ ],+ "nextTrackId": 3,+ "type": "mvhd-box",+ "boxSize": 108,+ "offset": 40+ },+ {+ "offset": 148,+ "boxSize": 3130,+ "type": "trak-box",+ "children": [+ {+ "offset": 156,+ "boxSize": 92,+ "type": "tkhd-box",+ "creationTime": null,+ "modificationTime": null,+ "trackId": 1,+ "duration": 5700,+ "layer": 0,+ "alternateGroup": 0,+ "volume": 0,+ "matrix": [+ 1,+ 0,+ 0,+ 0,+ 1,+ 0,+ 0,+ 0,+ 1+ ],+ "width": 404.9717559814453,+ "height": 720,+ "version": 0,+ "rotation": 0,+ "unrotatedWidth": 404.9717559814453,+ "unrotatedHeight": 720+ },+ {+ "type": "regular-box",+ "boxType": "edts",+ "boxSize": 36,+ "children": [],+ "offset": 248+ },+ {+ "type": "regular-box",+ "boxType": "mdia",+ "boxSize": 2994,+ "children": [+ {+ "type": "mdhd-box",+ "duration": 87552,+ "timescale": 15360,+ "version": 0,+ "language": 21956,+ "quality": 0+ },+ {+ "type": "regular-box",+ "boxType": "hdlr",+ "boxSize": 45,+ "children": [],+ "offset": 324+ },+ {+ "type": "regular-box",+ "boxType": "minf",+ "boxSize": 2909,+ "children": [+ {+ "type": "regular-box",+ "boxType": "vmhd",+ "boxSize": 20,+ "children": [],+ "offset": 377+ },+ {+ "type": "regular-box",+ "boxType": "dinf",+ "boxSize": 36,+ "children": [],+ "offset": 397+ },+ {+ "type": "regular-box",+ "boxType": "stbl",+ "boxSize": 2845,+ "children": [+ {+ "type": "stsd-box",+ "boxSize": 197,+ "offset": 441,+ "numberOfEntries": 1,+ "samples": [+ {+ "format": "avc1",+ "offset": 457,+ "dataReferenceIndex": 1,+ "version": 0,+ "revisionLevel": 0,+ "vendor": [+ 0,+ 0,+ 0,+ 0+ ],+ "size": 181,+ "type": "video",+ "width": 1280,+ "height": 720,+ "horizontalResolutionPpi": 72,+ "verticalResolutionPpi": 72,+ "spacialQuality": 0,+ "temporalQuality": 0,+ "dataSize": 0,+ "frameCountPerSample": 1,+ "compressorName": [+ 0,+ 0,+ 0,+ 0,+ 0,+ 0,+ 0,+ 0,+ 0,+ 0,+ 0,+ 0,+ 0,+ 0,+ 0,+ 0,+ 0,+ 0,+ 0,+ 0,+ 0,+ 0,+ 0,+ 0,+ 0,+ 0,+ 0,+ 0,+ 0,+ 0,+ 0,+ 0+ ],+ "depth": 24,+ "colorTableId": -1,+ "descriptors": [+ {+ "type": "avcc-box",+ "data": {+ "0": 1,+ "1": 100,+ "2": 0,+ "3": 31,+ "4": 255,+ "5": 225,+ "6": 0,+ "7": 30,+ "8": 103,+ "9": 100,+ "10": 0,+ "11": 31,+ "12": 172,+ "13": 217,+ "14": 64,+ "15": 80,+ "16": 5,+ "17": 187,+ "18": 255,+ "19": 0,+ "20": 56,+ "21": 0,+ "22": 177,+ "23": 16,+ "24": 0,+ "25": 0,+ "26": 3,+ "27": 0,+ "28": 16,+ "29": 0,+ "30": 0,+ "31": 3,+ "32": 3,+ "33": 192,+ "34": 241,+ "35": 131,+ "36": 25,+ "37": 96,+ "38": 1,+ "39": 0,+ "40": 6,+ "41": 104,+ "42": 235,+ "43": 227,+ "44": 203,+ "45": 34,+ "46": 192,+ "47": 253,+ "48": 248,+ "49": 248,+ "50": 0+ },+ "configurationString": "64001f"+ },+ {+ "type": "pasp-box",+ "boxSize": 16,+ "offset": 602,+ "hSpacing": 56,+ "vSpacing": 177+ },+ {+ "type": "regular-box",+ "boxType": "btrt",+ "boxSize": 20,+ "children": [],+ "offset": 618+ }+ ]+ }+ ]+ },+ {+ "type": "stts-box",+ "sampleDistribution": [+ {+ "sampleCount": 171,+ "sampleDelta": 512+ }+ ]+ },+ {+ "type": "stss-box",+ "version": 0,+ "flags": [+ 0,+ 0,+ 0+ ],+ "sampleNumber": [+ 1,+ 33+ ],+ "boxSize": 24,+ "offset": 662+ },+ {+ "type": "ctts-box",+ "boxSize": 1152,+ "offset": 686,+ "version": 0,+ "flags": [+ 0,+ 0,+ 0+ ],+ "entryCount": 142,+ "entries": [+ {+ "sampleCount": 1,+ "sampleOffset": 1024+ },+ {+ "sampleCount": 1,+ "sampleOffset": 2560+ },+ {+ "sampleCount": 1,+ "sampleOffset": 1024+ },+ {+ "sampleCount": 1,+ "sampleOffset": 0+ },+ {+ "sampleCount": 1,+ "sampleOffset": 512+ },+ {+ "sampleCount": 1,+ "sampleOffset": 2560+ },+ {+ "sampleCount": 1,+ "sampleOffset": 1024+ },+ {+ "sampleCount": 1,+ "sampleOffset": 0+ },+ {+ "sampleCount": 1,+ "sampleOffset": 512+ },+ {+ "sampleCount": 1,+ "sampleOffset": 2560+ },+ {+ "sampleCount": 1,+ "sampleOffset": 1024+ },+ {+ "sampleCount": 1,+ "sampleOffset": 0+ },+ {+ "sampleCount": 1,+ "sampleOffset": 512+ },+ {+ "sampleCount": 1,+ "sampleOffset": 2560+ },+ {+ "sampleCount": 1,+ "sampleOffset": 1024+ },+ {+ "sampleCount": 1,+ "sampleOffset": 0+ },+ {+ "sampleCount": 1,+ "sampleOffset": 512+ },+ {+ "sampleCount": 1,+ "sampleOffset": 2048+ },+ {+ "sampleCount": 2,+ "sampleOffset": 512+ },+ {+ "sampleCount": 13,+ "sampleOffset": 1024+ },+ {+ "sampleCount": 1,+ "sampleOffset": 2560+ },+ {+ "sampleCount": 1,+ "sampleOffset": 1024+ },+ {+ "sampleCount": 1,+ "sampleOffset": 0+ },+ {+ "sampleCount": 1,+ "sampleOffset": 512+ },+ {+ "sampleCount": 1,+ "sampleOffset": 2560+ },+ {+ "sampleCount": 1,+ "sampleOffset": 1024+ },+ {+ "sampleCount": 1,+ "sampleOffset": 0+ },+ {+ "sampleCount": 1,+ "sampleOffset": 512+ },+ {+ "sampleCount": 1,+ "sampleOffset": 2048+ },+ {+ "sampleCount": 2,+ "sampleOffset": 512+ },+ {+ "sampleCount": 13,+ "sampleOffset": 1024+ },+ {+ "sampleCount": 1,+ "sampleOffset": 1536+ },+ {+ "sampleCount": 1,+ "sampleOffset": 512+ },+ {+ "sampleCount": 1,+ "sampleOffset": 1536+ },+ {+ "sampleCount": 1,+ "sampleOffset": 512+ },+ {+ "sampleCount": 1,+ "sampleOffset": 2560+ },+ {+ "sampleCount": 1,+ "sampleOffset": 1024+ },+ {+ "sampleCount": 1,+ "sampleOffset": 0+ },+ {+ "sampleCount": 1,+ "sampleOffset": 512+ },+ {+ "sampleCount": 1,+ "sampleOffset": 1536+ },+ {+ "sampleCount": 1,+ "sampleOffset": 512+ },+ {+ "sampleCount": 4,+ "sampleOffset": 1024+ },+ {+ "sampleCount": 1,+ "sampleOffset": 2560+ },+ {+ "sampleCount": 1,+ "sampleOffset": 1024+ },+ {+ "sampleCount": 1,+ "sampleOffset": 0+ },+ {+ "sampleCount": 1,+ "sampleOffset": 512+ },+ {+ "sampleCount": 1,+ "sampleOffset": 2560+ },+ {+ "sampleCount": 1,+ "sampleOffset": 1024+ },+ {+ "sampleCount": 1,+ "sampleOffset": 0+ },+ {+ "sampleCount": 1,+ "sampleOffset": 512+ },+ {+ "sampleCount": 1,+ "sampleOffset": 2560+ },+ {+ "sampleCount": 1,+ "sampleOffset": 1024+ },+ {+ "sampleCount": 1,+ "sampleOffset": 0+ },+ {+ "sampleCount": 1,+ "sampleOffset": 512+ },+ {+ "sampleCount": 1,+ "sampleOffset": 2560+ },+ {+ "sampleCount": 1,+ "sampleOffset": 1024+ },+ {+ "sampleCount": 1,+ "sampleOffset": 0+ },+ {+ "sampleCount": 1,+ "sampleOffset": 512+ },+ {+ "sampleCount": 1,+ "sampleOffset": 2560+ },+ {+ "sampleCount": 1,+ "sampleOffset": 1024+ },+ {+ "sampleCount": 1,+ "sampleOffset": 0+ },+ {+ "sampleCount": 1,+ "sampleOffset": 512+ },+ {+ "sampleCount": 1,+ "sampleOffset": 2560+ },+ {+ "sampleCount": 1,+ "sampleOffset": 1024+ },+ {+ "sampleCount": 1,+ "sampleOffset": 0+ },+ {+ "sampleCount": 1,+ "sampleOffset": 512+ },+ {+ "sampleCount": 1,+ "sampleOffset": 2560+ },+ {+ "sampleCount": 1,+ "sampleOffset": 1024+ },+ {+ "sampleCount": 1,+ "sampleOffset": 0+ },+ {+ "sampleCount": 1,+ "sampleOffset": 512+ },+ {+ "sampleCount": 1,+ "sampleOffset": 2560+ },+ {+ "sampleCount": 1,+ "sampleOffset": 1024+ },+ {+ "sampleCount": 1,+ "sampleOffset": 0+ },+ {+ "sampleCount": 1,+ "sampleOffset": 512+ },+ {+ "sampleCount": 1,+ "sampleOffset": 2560+ },+ {+ "sampleCount": 1,+ "sampleOffset": 1024+ },+ {+ "sampleCount": 1,+ "sampleOffset": 0+ },+ {+ "sampleCount": 1,+ "sampleOffset": 512+ },+ {+ "sampleCount": 1,+ "sampleOffset": 2560+ },+ {+ "sampleCount": 1,+ "sampleOffset": 1024+ },+ {+ "sampleCount": 1,+ "sampleOffset": 0+ },+ {+ "sampleCount": 1,+ "sampleOffset": 512+ },+ {+ "sampleCount": 1,+ "sampleOffset": 2560+ },+ {+ "sampleCount": 1,+ "sampleOffset": 1024+ },+ {+ "sampleCount": 1,+ "sampleOffset": 0+ },+ {+ "sampleCount": 1,+ "sampleOffset": 512+ },+ {+ "sampleCount": 1,+ "sampleOffset": 2560+ },+ {+ "sampleCount": 1,+ "sampleOffset": 1024+ },+ {+ "sampleCount": 1,+ "sampleOffset": 0+ },+ {+ "sampleCount": 1,+ "sampleOffset": 512+ },+ {+ "sampleCount": 1,+ "sampleOffset": 2560+ },+ {+ "sampleCount": 1,+ "sampleOffset": 1024+ },+ {+ "sampleCount": 1,+ "sampleOffset": 0+ },+ {+ "sampleCount": 1,+ "sampleOffset": 512+ },+ {+ "sampleCount": 1,+ "sampleOffset": 2560+ },+ {+ "sampleCount": 1,+ "sampleOffset": 1024+ },+ {+ "sampleCount": 1,+ "sampleOffset": 0+ },+ {+ "sampleCount": 1,+ "sampleOffset": 512+ },+ {+ "sampleCount": 1,+ "sampleOffset": 2560+ },+ {+ "sampleCount": 1,+ "sampleOffset": 1024+ },+ {+ "sampleCount": 1,+ "sampleOffset": 0+ },+ {+ "sampleCount": 1,+ "sampleOffset": 512+ },+ {+ "sampleCount": 1,+ "sampleOffset": 2560+ },+ {+ "sampleCount": 1,+ "sampleOffset": 1024+ },+ {+ "sampleCount": 1,+ "sampleOffset": 0+ },+ {+ "sampleCount": 1,+ "sampleOffset": 512+ },+ {+ "sampleCount": 1,+ "sampleOffset": 2560+ },+ {+ "sampleCount": 1,+ "sampleOffset": 1024+ },+ {+ "sampleCount": 1,+ "sampleOffset": 0+ },+ {+ "sampleCount": 1,+ "sampleOffset": 512+ },+ {+ "sampleCount": 1,+ "sampleOffset": 2560+ },+ {+ "sampleCount": 1,+ "sampleOffset": 1024+ },+ {+ "sampleCount": 1,+ "sampleOffset": 0+ },+ {+ "sampleCount": 1,+ "sampleOffset": 512+ },+ {+ "sampleCount": 1,+ "sampleOffset": 2560+ },+ {+ "sampleCount": 1,+ "sampleOffset": 1024+ },+ {+ "sampleCount": 1,+ "sampleOffset": 0+ },+ {+ "sampleCount": 1,+ "sampleOffset": 512+ },+ {+ "sampleCount": 1,+ "sampleOffset": 2560+ },+ {+ "sampleCount": 1,+ "sampleOffset": 1024+ },+ {+ "sampleCount": 1,+ "sampleOffset": 0+ },+ {+ "sampleCount": 1,+ "sampleOffset": 512+ },+ {+ "sampleCount": 1,+ "sampleOffset": 2560+ },+ {+ "sampleCount": 1,+ "sampleOffset": 1024+ },+ {+ "sampleCount": 1,+ "sampleOffset": 0+ },+ {+ "sampleCount": 1,+ "sampleOffset": 512+ },+ {+ "sampleCount": 1,+ "sampleOffset": 2560+ },+ {+ "sampleCount": 1,+ "sampleOffset": 1024+ },+ {+ "sampleCount": 1,+ "sampleOffset": 0+ },+ {+ "sampleCount": 1,+ "sampleOffset": 512+ },+ {+ "sampleCount": 1,+ "sampleOffset": 2560+ },+ {+ "sampleCount": 1,+ "sampleOffset": 1024+ },+ {+ "sampleCount": 1,+ "sampleOffset": 0+ },+ {+ "sampleCount": 1,+ "sampleOffset": 512+ },+ {+ "sampleCount": 1,+ "sampleOffset": 2560+ },+ {+ "sampleCount": 1,+ "sampleOffset": 1024+ },+ {+ "sampleCount": 1,+ "sampleOffset": 0+ },+ {+ "sampleCount": 1,+ "sampleOffset": 512+ },+ {+ "sampleCount": 1,+ "sampleOffset": 2560+ },+ {+ "sampleCount": 1,+ "sampleOffset": 1024+ },+ {+ "sampleCount": 1,+ "sampleOffset": 0+ },+ {+ "sampleCount": 1,+ "sampleOffset": 512+ }+ ]+ },+ {+ "type": "stsc-box",+ "boxSize": 40,+ "offset": 1838,+ "version": 0,+ "flags": [+ 0,+ 0,+ 0+ ],+ "entryCount": 2,+ "entries": [+ {+ "firstChunk": 1,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 2,+ "samplesPerChunk": 1+ }+ ]+ },+ {+ "type": "stsz-box",+ "boxSize": 704,+ "offset": 1878,+ "version": 0,+ "flags": [+ 0,+ 0,+ 0+ ],+ "sampleCount": 171,+ "countType": "variable",+ "entries": [+ 1725,+ 439,+ 301,+ 127,+ 150,+ 464,+ 306,+ 99,+ 182,+ 552,+ 346,+ 235,+ 328,+ 531,+ 496,+ 216,+ 329,+ 667,+ 312,+ 332,+ 1436,+ 18331,+ 24767,+ 30638,+ 37033,+ 40871,+ 45520,+ 47903,+ 48646,+ 48968,+ 49073,+ 47246,+ 66081,+ 44620,+ 44392,+ 39625,+ 34043,+ 36566,+ 34207,+ 27497,+ 22077,+ 27023,+ 20139,+ 15038,+ 18497,+ 14809,+ 14673,+ 11944,+ 12792,+ 9315,+ 9795,+ 7869,+ 8182,+ 7209,+ 7152,+ 6409,+ 7634,+ 7035,+ 3385,+ 6727,+ 3174,+ 7839,+ 4374,+ 2722,+ 2472,+ 4484,+ 2166,+ 2883,+ 3509,+ 2430,+ 2405,+ 5235,+ 2684,+ 1645,+ 1593,+ 4453,+ 2558,+ 1657,+ 1492,+ 5717,+ 2736,+ 1642,+ 1568,+ 4939,+ 1992,+ 1281,+ 1238,+ 3307,+ 1541,+ 1025,+ 899,+ 3167,+ 1314,+ 764,+ 718,+ 2767,+ 974,+ 677,+ 561,+ 1632,+ 769,+ 582,+ 484,+ 1489,+ 728,+ 423,+ 513,+ 1516,+ 649,+ 472,+ 381,+ 1642,+ 549,+ 375,+ 367,+ 1255,+ 509,+ 370,+ 330,+ 1407,+ 500,+ 368,+ 300,+ 1123,+ 443,+ 357,+ 252,+ 2897,+ 576,+ 359,+ 326,+ 1046,+ 422,+ 259,+ 249,+ 1211,+ 407,+ 235,+ 211,+ 421,+ 268,+ 256,+ 235,+ 331,+ 253,+ 199,+ 179,+ 218,+ 258,+ 242,+ 200,+ 176,+ 255,+ 189,+ 192,+ 286,+ 217,+ 168,+ 195,+ 266,+ 255,+ 203,+ 194,+ 79,+ 247,+ 177,+ 156,+ 105,+ 237,+ 185,+ 173+ ]+ },+ {+ "type": "stco-box",+ "boxSize": 696,+ "offset": 2582,+ "version": 0,+ "flags": [+ 0,+ 0,+ 0+ ],+ "entries": [+ 7481,+ 9669,+ 9982,+ 10115,+ 10277,+ 10747,+ 11065,+ 11176,+ 11364,+ 11928,+ 12280,+ 12527,+ 12861,+ 13404,+ 13906,+ 14134,+ 14475,+ 15201,+ 16638,+ 17620,+ 20297,+ 39076,+ 64764,+ 96182,+ 133636,+ 175163,+ 221062,+ 269672,+ 318686,+ 368342,+ 417774,+ 465711,+ 532460,+ 577532,+ 622781,+ 662695,+ 697363,+ 734263,+ 769117,+ 797304,+ 819710,+ 847403,+ 867867,+ 883592,+ 902427,+ 917920,+ 932940,+ 945587,+ 959064,+ 968725,+ 979253,+ 987471,+ 996357,+ 1003925,+ 1011795,+ 1018890,+ 1026873,+ 1034594,+ 1038314,+ 1045740,+ 1049266,+ 1057756,+ 1062489,+ 1065937,+ 1069152,+ 1073991,+ 1076817,+ 1080043,+ 1084242,+ 1087038,+ 1090148,+ 1096083,+ 1099083,+ 1101372,+ 1103296,+ 1108421,+ 1111317,+ 1113612,+ 1115403,+ 1121777,+ 1125127,+ 1127159,+ 1129444,+ 1134766,+ 1137413,+ 1139044,+ 1140962,+ 1144967,+ 1146862,+ 1148556,+ 1149853,+ 1153702,+ 1155364,+ 1156790,+ 1157840,+ 1161279,+ 1162940,+ 1163983,+ 1165206,+ 1167190,+ 1168588,+ 1169513,+ 1170694,+ 1172846,+ 1173926,+ 1175048,+ 1175922,+ 1178166,+ 1179138,+ 1180292,+ 1181034,+ 1183324,+ 1184599,+ 1185323,+ 1186339,+ 1187937,+ 1189113,+ 1189840,+ 1190896,+ 1192922,+ 1193745,+ 1194767,+ 1195447,+ 1197276,+ 1198038,+ 1199040,+ 1199660,+ 1203278,+ 1204549,+ 1205229,+ 1206160,+ 1207561,+ 1208659,+ 1209268,+ 1210214,+ 1212123,+ 1212883,+ 1213783,+ 1214379,+ 1215437,+ 1216055,+ 1216988,+ 1217562,+ 1218589,+ 1219542,+ 1220062,+ 1220966,+ 1221548,+ 1222490,+ 1223040,+ 1223921,+ 1224795,+ 1225370,+ 1226244,+ 1226776,+ 1227739,+ 1228278,+ 1229164,+ 1229696,+ 1230632,+ 1231561,+ 1232128,+ 1232971,+ 1233402,+ 1234328,+ 1234899,+ 1235725,+ 1236551,+ 1237114,+ 1237974+ ],+ "entryCount": 170+ }+ ],+ "offset": 433+ }+ ],+ "offset": 369+ }+ ],+ "offset": 284+ }+ ]+ },+ {+ "offset": 3278,+ "boxSize": 4089,+ "type": "trak-box",+ "children": [+ {+ "offset": 3286,+ "boxSize": 92,+ "type": "tkhd-box",+ "creationTime": null,+ "modificationTime": null,+ "trackId": 2,+ "duration": 5725,+ "layer": 0,+ "alternateGroup": 1,+ "volume": 256,+ "matrix": [+ 1,+ 0,+ 0,+ 0,+ 1,+ 0,+ 0,+ 0,+ 1+ ],+ "width": 0,+ "height": 0,+ "version": 0,+ "rotation": 0,+ "unrotatedWidth": 0,+ "unrotatedHeight": 0+ },+ {+ "type": "regular-box",+ "boxType": "edts",+ "boxSize": 36,+ "children": [],+ "offset": 3378+ },+ {+ "type": "regular-box",+ "boxType": "mdia",+ "boxSize": 3953,+ "children": [+ {+ "type": "mdhd-box",+ "duration": 274768,+ "timescale": 48000,+ "version": 0,+ "language": 21956,+ "quality": 0+ },+ {+ "type": "regular-box",+ "boxType": "hdlr",+ "boxSize": 45,+ "children": [],+ "offset": 3454+ },+ {+ "type": "regular-box",+ "boxType": "minf",+ "boxSize": 3868,+ "children": [+ {+ "type": "regular-box",+ "boxType": "smhd",+ "boxSize": 16,+ "children": [],+ "offset": 3507+ },+ {+ "type": "regular-box",+ "boxType": "dinf",+ "boxSize": 36,+ "children": [],+ "offset": 3523+ },+ {+ "type": "regular-box",+ "boxType": "stbl",+ "boxSize": 3808,+ "children": [+ {+ "type": "stsd-box",+ "boxSize": 126,+ "offset": 3567,+ "numberOfEntries": 1,+ "samples": [+ {+ "format": "mp4a",+ "offset": 3583,+ "dataReferenceIndex": 1,+ "version": 0,+ "revisionLevel": 0,+ "vendor": [+ 0,+ 0,+ 0,+ 0+ ],+ "size": 110,+ "type": "audio",+ "numberOfChannels": 2,+ "sampleSize": 16,+ "compressionId": 0,+ "packetSize": 0,+ "sampleRate": 48000,+ "samplesPerPacket": null,+ "bytesPerPacket": null,+ "bytesPerFrame": null,+ "bitsPerSample": null,+ "children": [+ {+ "type": "esds-box",+ "version": 0,+ "tag": 3,+ "sizeOfInstance": 37,+ "esId": 2,+ "descriptors": [+ {+ "type": "decoder-config-descriptor",+ "objectTypeIndication": "aac",+ "asNumber": 64+ },+ {+ "type": "sl-config-descriptor"+ }+ ]+ },+ {+ "type": "regular-box",+ "boxType": "btrt",+ "boxSize": 20,+ "children": [],+ "offset": 3673+ }+ ]+ }+ ]+ },+ {+ "type": "stts-box",+ "sampleDistribution": [+ {+ "sampleCount": 269,+ "sampleDelta": 1024+ }+ ]+ },+ {+ "type": "stsc-box",+ "boxSize": 1804,+ "offset": 3717,+ "version": 0,+ "flags": [+ 0,+ 0,+ 0+ ],+ "entryCount": 149,+ "entries": [+ {+ "firstChunk": 1,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 2,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 3,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 4,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 5,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 6,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 8,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 9,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 10,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 11,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 12,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 13,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 14,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 15,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 17,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 18,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 19,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 20,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 21,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 22,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 24,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 25,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 26,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 27,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 28,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 29,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 30,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 31,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 33,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 34,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 35,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 36,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 37,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 38,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 40,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 41,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 42,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 43,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 44,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 45,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 46,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 47,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 49,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 50,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 51,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 52,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 53,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 54,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 56,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 57,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 58,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 59,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 60,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 61,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 62,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 63,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 65,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 66,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 67,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 68,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 69,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 70,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 72,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 73,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 74,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 75,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 76,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 77,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 78,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 79,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 81,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 82,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 83,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 84,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 85,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 86,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 88,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 89,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 90,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 91,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 92,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 93,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 94,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 95,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 97,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 98,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 99,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 100,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 101,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 102,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 104,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 105,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 106,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 107,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 108,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 109,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 110,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 111,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 113,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 114,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 115,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 116,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 117,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 118,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 120,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 121,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 122,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 123,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 124,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 125,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 126,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 127,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 129,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 130,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 131,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 132,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 133,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 134,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 136,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 137,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 138,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 139,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 140,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 141,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 142,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 143,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 145,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 146,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 147,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 148,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 149,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 150,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 152,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 153,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 154,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 155,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 156,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 157,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 158,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 159,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 161,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 162,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 163,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 164,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 165,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 166,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 168,+ "samplesPerChunk": 1+ },+ {+ "firstChunk": 169,+ "samplesPerChunk": 2+ },+ {+ "firstChunk": 170,+ "samplesPerChunk": 5+ }+ ]+ },+ {+ "type": "stsz-box",+ "boxSize": 1096,+ "offset": 5521,+ "version": 0,+ "flags": [+ 0,+ 0,+ 0+ ],+ "sampleCount": 269,+ "countType": "variable",+ "entries": [+ 24,+ 6,+ 6,+ 6,+ 6,+ 6,+ 6,+ 6,+ 6,+ 6,+ 6,+ 6,+ 6,+ 6,+ 6,+ 6,+ 6,+ 6,+ 6,+ 6,+ 6,+ 6,+ 6,+ 6,+ 6,+ 59,+ 490,+ 635,+ 650,+ 639,+ 602,+ 448,+ 459,+ 462,+ 383,+ 397,+ 421,+ 326,+ 330,+ 379,+ 350,+ 357,+ 368,+ 363,+ 325,+ 359,+ 326,+ 365,+ 352,+ 316,+ 452,+ 434,+ 423,+ 289,+ 306,+ 319,+ 334,+ 321,+ 326,+ 351,+ 339,+ 329,+ 331,+ 339,+ 325,+ 337,+ 350,+ 338,+ 339,+ 345,+ 347,+ 339,+ 364,+ 337,+ 348,+ 346,+ 344,+ 389,+ 349,+ 358,+ 346,+ 359,+ 364,+ 354,+ 364,+ 322,+ 349,+ 332,+ 354,+ 335,+ 361,+ 338,+ 352,+ 342,+ 309,+ 359,+ 366,+ 360,+ 377,+ 366,+ 355,+ 339,+ 321,+ 343,+ 352,+ 338,+ 366,+ 349,+ 356,+ 355,+ 345,+ 316,+ 333,+ 311,+ 331,+ 322,+ 350,+ 338,+ 310,+ 328,+ 299,+ 325,+ 332,+ 279,+ 335,+ 390,+ 363,+ 354,+ 383,+ 359,+ 296,+ 350,+ 373,+ 307,+ 332,+ 366,+ 354,+ 332,+ 337,+ 398,+ 376,+ 306,+ 348,+ 335,+ 327,+ 332,+ 345,+ 327,+ 353,+ 334,+ 366,+ 335,+ 327,+ 352,+ 312,+ 317,+ 343,+ 346,+ 351,+ 325,+ 338,+ 352,+ 345,+ 354,+ 361,+ 336,+ 392,+ 323,+ 353,+ 329,+ 361,+ 315,+ 333,+ 328,+ 398,+ 349,+ 351,+ 298,+ 343,+ 346,+ 321,+ 357,+ 364,+ 362,+ 321,+ 298,+ 323,+ 339,+ 315,+ 380,+ 363,+ 343,+ 319,+ 317,+ 328,+ 368,+ 366,+ 355,+ 351,+ 344,+ 321,+ 295,+ 310,+ 355,+ 332,+ 344,+ 350,+ 380,+ 317,+ 347,+ 351,+ 353,+ 313,+ 352,+ 385,+ 302,+ 335,+ 350,+ 326,+ 351,+ 339,+ 354,+ 342,+ 344,+ 356,+ 321,+ 361,+ 364,+ 364,+ 366,+ 318,+ 308,+ 382,+ 299,+ 355,+ 343,+ 320,+ 361,+ 324,+ 340,+ 331,+ 346,+ 322,+ 372,+ 346,+ 337,+ 327,+ 343,+ 339,+ 335,+ 364,+ 292,+ 357,+ 352,+ 358,+ 321,+ 394,+ 300,+ 370,+ 336,+ 385,+ 326,+ 320,+ 355,+ 328,+ 332,+ 331,+ 337,+ 152+ ]+ },+ {+ "type": "stco-box",+ "boxSize": 696,+ "offset": 6617,+ "version": 0,+ "flags": [+ 0,+ 0,+ 0+ ],+ "entries": [+ 9645,+ 9970,+ 10109,+ 10265,+ 10741,+ 11053,+ 11164,+ 11358,+ 11916,+ 12274,+ 12515,+ 12855,+ 13392,+ 13900,+ 14122,+ 14463,+ 15142,+ 15513,+ 16970,+ 19056,+ 38628,+ 63843,+ 95402,+ 133215,+ 174507,+ 220683,+ 268965,+ 318318,+ 367654,+ 417415,+ 465020,+ 531792,+ 577080,+ 621924,+ 662406,+ 696738,+ 733929,+ 768470,+ 796614,+ 819381,+ 846733,+ 867542,+ 882905,+ 902089,+ 917236,+ 932593,+ 944884,+ 958379,+ 968379,+ 978520,+ 987122,+ 995653,+ 1003566,+ 1011077,+ 1018204,+ 1026524,+ 1033908,+ 1037979,+ 1045041,+ 1048914,+ 1057105,+ 1062130,+ 1065211,+ 1068409,+ 1073636,+ 1076157,+ 1079700,+ 1083552,+ 1086672,+ 1089443,+ 1095383,+ 1098767,+ 1100728,+ 1102965,+ 1107749,+ 1110979,+ 1112974,+ 1115104,+ 1121120,+ 1124513,+ 1126769,+ 1128727,+ 1134383,+ 1136758,+ 1138694,+ 1140282,+ 1144269,+ 1146508,+ 1147887,+ 1149455,+ 1153020,+ 1155016,+ 1156128,+ 1157508,+ 1160607,+ 1162253,+ 1163617,+ 1164544,+ 1166838,+ 1167959,+ 1169170,+ 1169997,+ 1172183,+ 1173574,+ 1174349,+ 1175561,+ 1177438,+ 1178815,+ 1179610,+ 1180673,+ 1182676,+ 1183873,+ 1184974,+ 1185690,+ 1187594,+ 1188446,+ 1189483,+ 1190170,+ 1192303,+ 1193422,+ 1194113,+ 1195067,+ 1196570,+ 1197719,+ 1198395,+ 1199292,+ 1202557,+ 1203854,+ 1204908,+ 1205555,+ 1207206,+ 1207983,+ 1208918,+ 1209517,+ 1211425,+ 1212530,+ 1213118,+ 1213994,+ 1214800,+ 1215705,+ 1216311,+ 1217223,+ 1217893,+ 1218842,+ 1219741,+ 1220241,+ 1221184,+ 1221806,+ 1222732,+ 1223240,+ 1224097,+ 1225050,+ 1225559,+ 1226436,+ 1227062,+ 1227956,+ 1228446,+ 1229359,+ 1229962,+ 1230887,+ 1231764,+ 1232322,+ 1233050,+ 1233649,+ 1234505,+ 1235055,+ 1235830,+ 1236788,+ 1237299,+ 1238147+ ],+ "entryCount": 170+ },+ {+ "type": "regular-box",+ "boxType": "sgpd",+ "boxSize": 26,+ "children": [],+ "offset": 7313+ },+ {+ "type": "regular-box",+ "boxType": "sbgp",+ "boxSize": 28,+ "children": [],+ "offset": 7339+ }+ ],+ "offset": 3559+ }+ ],+ "offset": 3499+ }+ ],+ "offset": 3414+ }+ ]+ },+ {+ "type": "regular-box",+ "boxType": "udta",+ "boxSize": 98,+ "children": [],+ "offset": 7367+ }+ ]+ },+ {+ "type": "regular-box",+ "boxType": "free",+ "boxSize": 8,+ "children": [],+ "offset": 7465+ },+ {+ "type": "regular-box",+ "boxType": "mdat",+ "children": [],+ "boxSize": 1232154,+ "offset": 7473+ }+]\ No newline at end of filediff --git a/packages/media-parser/src/boxes/iso-base-media/process-box.ts b/packages/media-parser/src/boxes/iso-base-media/process-box.tsindex e5062dad49..b3714af96a 100644--- a/packages/media-parser/src/boxes/iso-base-media/process-box.ts+++ b/packages/media-parser/src/boxes/iso-base-media/process-box.ts@@ -8,15 +8,16 @@ import type {} from '../../parse-result';import type {BoxAndNext} from '../../parse-video';import type {ParserContext} from '../../parser-context';-import {parseAvcc, parseHvcc} from './avcc-hvcc';import {parseEsds} from './esds/esds';import {parseFtyp} from './ftyp';import {parseMdat} from './mdat/mdat';import {parseMdhd} from './mdhd';import {parseMoov} from './moov/moov';import {parseMvhd} from './mvhd';+import {parseAvcc, parseHvcc} from './stsd/avcc-hvcc';import {parseCtts} from './stsd/ctts';import {parseMebx} from './stsd/mebx';+import {parsePasp} from './stsd/pasp';import {parseStco} from './stsd/stco';import {parseStsc} from './stsd/stsc';import {parseStsd} from './stsd/stsd';@@ -218,6 +219,21 @@ const processBox = ({};}+ if (boxType === 'pasp') {+ const box = parsePasp({+ iterator,+ offset: fileOffset,+ size: boxSize,+ });++ return {+ type: 'complete',+ box,+ size: boxSize,+ skipTo: null,+ };+ }+if (boxType === 'stss') {const box = parseStss({iterator,diff --git a/packages/media-parser/src/boxes/iso-base-media/avcc-hvcc.ts b/packages/media-parser/src/boxes/iso-base-media/stsd/avcc-hvcc.tssimilarity index 97%rename from packages/media-parser/src/boxes/iso-base-media/avcc-hvcc.tsrename to packages/media-parser/src/boxes/iso-base-media/stsd/avcc-hvcc.tsindex d31667547c..173e86f95a 100644--- a/packages/media-parser/src/boxes/iso-base-media/avcc-hvcc.ts+++ b/packages/media-parser/src/boxes/iso-base-media/stsd/avcc-hvcc.ts@@ -1,4 +1,4 @@-import type {BufferIterator} from '../../buffer-iterator';+import type {BufferIterator} from '../../../buffer-iterator';export interface AvccBox {type: 'avcc-box';diff --git a/packages/media-parser/src/boxes/iso-base-media/stsd/pasp.ts b/packages/media-parser/src/boxes/iso-base-media/stsd/pasp.tsnew file mode 100644index 0000000000..ac4bd9de1d--- /dev/null+++ b/packages/media-parser/src/boxes/iso-base-media/stsd/pasp.ts@@ -0,0 +1,32 @@+import type {BufferIterator} from '../../../buffer-iterator';+import type {BaseBox} from '../base-type';++export interface PaspBox extends BaseBox {+ type: 'pasp-box';+ hSpacing: number;+ vSpacing: number;+}++export const parsePasp = ({+ iterator,+ offset,+ size,+}: {+ iterator: BufferIterator;+ offset: number;+ size: number;+}): PaspBox => {+ const hSpacing = iterator.getUint32();+ const vSpacing = iterator.getUint32();++ const bytesRemainingInBox = size - (iterator.counter.getOffset() - offset);+ iterator.discard(bytesRemainingInBox);++ return {+ type: 'pasp-box',+ boxSize: size,+ offset,+ hSpacing,+ vSpacing,+ };+};diff --git a/packages/media-parser/src/boxes/iso-base-media/stsd/samples.ts b/packages/media-parser/src/boxes/iso-base-media/stsd/samples.tsindex 07b771568e..0855f5b833 100644--- a/packages/media-parser/src/boxes/iso-base-media/stsd/samples.ts+++ b/packages/media-parser/src/boxes/iso-base-media/stsd/samples.ts@@ -27,7 +27,7 @@ export type AudioSample = SampleBase & {children: AnySegment[];};-type VideoSample = SampleBase & {+export type VideoSample = SampleBase & {type: 'video';temporalQuality: number;spacialQuality: number;diff --git a/packages/media-parser/src/get-sample-aspect-ratio.ts b/packages/media-parser/src/get-sample-aspect-ratio.tsnew file mode 100644index 0000000000..d0b1544cd2--- /dev/null+++ b/packages/media-parser/src/get-sample-aspect-ratio.ts@@ -0,0 +1,85 @@+import type {AvccBox, HvccBox} from './boxes/iso-base-media/stsd/avcc-hvcc';+import type {PaspBox} from './boxes/iso-base-media/stsd/pasp';+import type {VideoSample} from './boxes/iso-base-media/stsd/samples';+import type {TrakBox} from './boxes/iso-base-media/trak/trak';+import {getStsdBox} from './traversal';++type SampleAspectRatio = {+ numerator: number;+ denominator: number;+};++export const getVideoSample = (trakBox: TrakBox): VideoSample | null => {+ const stsdBox = getStsdBox(trakBox);++ if (!stsdBox) {+ return null;+ }++ const videoSample = stsdBox.samples.find((s) => s.type === 'video');+ if (!videoSample || videoSample.type !== 'video') {+ return null;+ }++ return videoSample;+};++export const getAvccBox = (trakBox: TrakBox): AvccBox | null => {+ const videoSample = getVideoSample(trakBox);+ if (!videoSample) {+ return null;+ }++ const avccBox = videoSample.descriptors.find((c) => c.type === 'avcc-box');++ if (!avccBox || avccBox.type !== 'avcc-box') {+ return null;+ }++ return avccBox;+};++export const getPaspBox = (trakBox: TrakBox): PaspBox | null => {+ const videoSample = getVideoSample(trakBox);+ if (!videoSample) {+ return null;+ }++ const paspBox = videoSample.descriptors.find((c) => c.type === 'pasp-box');++ if (!paspBox || paspBox.type !== 'pasp-box') {+ return null;+ }++ return paspBox;+};++export const getHvccBox = (trakBox: TrakBox): HvccBox | null => {+ const videoSample = getVideoSample(trakBox);+ if (!videoSample) {+ return null;+ }++ const hvccBox = videoSample.descriptors.find((c) => c.type === 'hvcc-box');++ if (!hvccBox || hvccBox.type !== 'hvcc-box') {+ return null;+ }++ return hvccBox;+};++export const getSampleAspectRatio = (trakBox: TrakBox): SampleAspectRatio => {+ const paspBox = getPaspBox(trakBox);+ if (!paspBox) {+ return {+ numerator: 1,+ denominator: 1,+ };+ }++ return {+ numerator: paspBox.hSpacing,+ denominator: paspBox.vSpacing,+ };+};diff --git a/packages/media-parser/src/get-tracks.ts b/packages/media-parser/src/get-tracks.tsindex 850ce8a31b..2302d22ca3 100644--- a/packages/media-parser/src/get-tracks.ts+++ b/packages/media-parser/src/get-tracks.ts@@ -5,6 +5,7 @@ import {trakBoxContainsAudio,trakBoxContainsVideo,} from './get-fps';+import {getSampleAspectRatio} from './get-sample-aspect-ratio';import type {SamplePosition} from './get-sample-positions';import {getSamplePositions} from './get-sample-positions';import {getVideoCodecString} from './get-video-codec';@@ -24,6 +25,11 @@ import {getVideoDescriptors,} from './traversal';+type SampleAspectRatio = {+ numerator: number;+ denominator: number;+};+export type VideoTrack = {type: 'video';samplePositions: SamplePosition[];@@ -31,6 +37,7 @@ export type VideoTrack = {description: Uint8Array | null;timescale: number;codecString: string | null;+ sampleAspectRatio: SampleAspectRatio;};export type AudioTrack = {@@ -152,6 +159,7 @@ export const getTracks = (description: videoDescriptors,timescale: timescaleAndDuration.timescale,codecString: getVideoCodecString(track),+ sampleAspectRatio: getSampleAspectRatio(track),});}}diff --git a/packages/media-parser/src/get-video-codec.ts b/packages/media-parser/src/get-video-codec.tsindex aca9cce709..91e80b21de 100644--- a/packages/media-parser/src/get-video-codec.ts+++ b/packages/media-parser/src/get-video-codec.ts@@ -1,6 +1,11 @@/* eslint-disable max-depth */import type {TrakBox} from './boxes/iso-base-media/trak/trak';import {trakBoxContainsVideo} from './get-fps';+import {+ getAvccBox,+ getHvccBox,+ getVideoSample,+} from './get-sample-aspect-ratio';import type {KnownVideoCodecs} from './options';import type {AnySegment} from './parse-result';import {getMoovBox, getStsdBox, getTraks} from './traversal';@@ -14,29 +19,23 @@ export const hasVideoCodec = (boxes: AnySegment[]): boolean => {};export const getVideoCodecString = (trakBox: TrakBox): string | null => {- const stsdBox = getStsdBox(trakBox);- if (stsdBox && stsdBox.type === 'stsd-box') {- const videoSample = stsdBox.samples.find((s) => s.type === 'video');- if (videoSample && videoSample.type === 'video') {- const avccBox = videoSample.descriptors.find(- (c) => c.type === 'avcc-box',- );- if (avccBox && avccBox.type === 'avcc-box') {- return `${videoSample.format}.${avccBox.configurationString}`;- }+ const videoSample = getVideoSample(trakBox);+ const avccBox = getAvccBox(trakBox);+ const hvccBox = getHvccBox(trakBox);- const hvccBox = videoSample.descriptors.find(- (c) => c.type === 'hvcc-box',- );- if (hvccBox && hvccBox.type === 'hvcc-box') {- return `${videoSample.format}.${hvccBox.configurationString}`;- }+ if (!videoSample) {+ return null;+ }- return videoSample.format;- }+ if (avccBox) {+ return `${videoSample.format}.${avccBox.configurationString}`;}- return null;+ if (hvccBox) {+ return `${videoSample.format}.${hvccBox.configurationString}`;+ }++ return videoSample.format;};export const getVideoCodec = (boxes: AnySegment[]): KnownVideoCodecs | null => {diff --git a/packages/media-parser/src/parse-result.ts b/packages/media-parser/src/parse-result.tsindex 418984d0e5..6258c44a80 100644--- a/packages/media-parser/src/parse-result.ts+++ b/packages/media-parser/src/parse-result.ts@@ -1,4 +1,3 @@-import type {AvccBox, HvccBox} from './boxes/iso-base-media/avcc-hvcc';import type {BaseBox} from './boxes/iso-base-media/base-type';import type {EsdsBox} from './boxes/iso-base-media/esds/esds';import type {FtypBox} from './boxes/iso-base-media/ftyp';@@ -6,9 +5,11 @@ import type {MdatBox} from './boxes/iso-base-media/mdat/mdat';import type {MdhdBox} from './boxes/iso-base-media/mdhd';import type {MoovBox} from './boxes/iso-base-media/moov/moov';import type {MvhdBox} from './boxes/iso-base-media/mvhd';+import type {AvccBox, HvccBox} from './boxes/iso-base-media/stsd/avcc-hvcc';import type {CttsBox} from './boxes/iso-base-media/stsd/ctts';import type {KeysBox} from './boxes/iso-base-media/stsd/keys';import type {MebxBox} from './boxes/iso-base-media/stsd/mebx';+import type {PaspBox} from './boxes/iso-base-media/stsd/pasp';import type {StcoBox} from './boxes/iso-base-media/stsd/stco';import type {StscBox} from './boxes/iso-base-media/stsd/stsc';import type {StsdBox} from './boxes/iso-base-media/stsd/stsd';@@ -49,6 +50,7 @@ export type IsoBaseMediaBox =| HvccBox| VoidBox| StssBox+ | PaspBox| CttsBox;export type AnySegment = MatroskaSegment | IsoBaseMediaBox;diff --git a/packages/media-parser/src/test/stream-local.test.ts b/packages/media-parser/src/test/stream-local.test.tsindex 9498447461..3688992273 100644--- a/packages/media-parser/src/test/stream-local.test.ts+++ b/packages/media-parser/src/test/stream-local.test.ts@@ -273,3 +273,43 @@ test('Should get duration of HEVC video', async () => {});expect(parsed.videoCodec).toBe('h265');});++test('Custom DAR', async () => {+ const parsed = await parseMedia({+ src: RenderInternals.exampleVideos.customDar,+ fields: {+ durationInSeconds: true,+ fps: true,+ videoCodec: true,+ audioCodec: true,+ tracks: true,+ dimensions: true,+ rotation: true,+ unrotatedDimension: true,+ boxes: true,+ },+ reader: nodeReader,+ });++ await Bun.write('dar.json', JSON.stringify(parsed.boxes, null, 2));++ expect(parsed.videoTracks[0].sampleAspectRatio).toEqual({+ numerator: 56,+ denominator: 177,+ });+ expect(parsed.dimensions).toEqual({+ height: 720,+ width: 1280,+ });+ expect(parsed.durationInSeconds).toBe(5.725);+ expect(parsed.fps).toBe(30);+ expect(parsed.videoCodec).toBe('h264');+ expect(parsed.audioCodec).toBe('aac');+ expect(parsed.videoTracks.length).toEqual(1);+ expect(parsed.videoTracks[0].codecString).toBe('avc1.64001f');+ expect(parsed.rotation).toBe(0);+ expect(parsed.unrotatedDimension).toEqual({+ height: 720,+ width: 404.9717559814453,+ });+});diff --git a/packages/media-parser/src/test/stream-samples.test.ts b/packages/media-parser/src/test/stream-samples.test.tsindex 776bdb3d4a..8e36b3b2d6 100644--- a/packages/media-parser/src/test/stream-samples.test.ts+++ b/packages/media-parser/src/test/stream-samples.test.ts@@ -109,6 +109,10 @@ test('Stream samples', async () => {description,timescale: 15360,codecString: 'avc1.640020',+ sampleAspectRatio: {+ numerator: 1,+ denominator: 1,+ },},]);diff --git a/packages/media-parser/src/test/stsd.test.ts b/packages/media-parser/src/test/stsd.test.tsindex 50d8d987de..97088206fc 100644--- a/packages/media-parser/src/test/stsd.test.ts+++ b/packages/media-parser/src/test/stsd.test.ts@@ -228,10 +228,10 @@ test('Should be able to parse a STSD video box correctly', () => {},{boxSize: 16,- boxType: 'pasp',- children: [],offset: 142,- type: 'regular-box',+ type: 'pasp-box',+ hSpacing: 1,+ vSpacing: 1,},],});