@remotion/webcodecs 4.0.273 → 4.0.275

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,7 +7,9 @@ const canCopyAudioTrack = ({ inputCodec, outputContainer, inputContainer, }) =>
7
7
  }
8
8
  if (outputContainer === 'mp4') {
9
9
  return (inputCodec === 'aac' &&
10
- (inputContainer === 'mp4' || inputContainer === 'avi'));
10
+ (inputContainer === 'mp4' ||
11
+ inputContainer === 'avi' ||
12
+ inputContainer === 'm3u8'));
11
13
  }
12
14
  if (outputContainer === 'wav') {
13
15
  return false;
@@ -26,7 +26,9 @@ const canCopyVideoTrack = ({ outputContainer, rotationToApply, inputContainer, r
26
26
  if (outputContainer === 'mp4') {
27
27
  return ((inputTrack.codecWithoutConfig === 'h264' ||
28
28
  inputTrack.codecWithoutConfig === 'h265') &&
29
- (inputContainer === 'mp4' || inputContainer === 'avi'));
29
+ (inputContainer === 'mp4' ||
30
+ inputContainer === 'avi' ||
31
+ (inputContainer === 'm3u8' && inputTrack.m3uStreamFormat === 'mp4')));
30
32
  }
31
33
  if (outputContainer === 'wav') {
32
34
  return false;
@@ -174,12 +174,15 @@ const createMatroskaMedia = async ({ writer, onBytesProgress, onMillisecondsProg
174
174
  async waitForFinish() {
175
175
  await Promise.all(waitForFinishPromises.map((p) => p()));
176
176
  await operationProm.current;
177
- seeks.push({
178
- hexString: matroskaElements.Cues,
179
- byte: w.getWrittenByteCount() - seekHeadOffset,
180
- });
177
+ const cuesBytes = (0, matroska_cues_1.createMatroskaCues)(cues);
178
+ if (cuesBytes) {
179
+ seeks.push({
180
+ hexString: matroskaElements.Cues,
181
+ byte: w.getWrittenByteCount() - seekHeadOffset,
182
+ });
183
+ await w.write(cuesBytes.bytes);
184
+ }
181
185
  await updateSeekWrite();
182
- await w.write((0, matroska_cues_1.createMatroskaCues)(cues).bytes);
183
186
  const segmentSize = w.getWrittenByteCount() -
184
187
  segmentOffset -
185
188
  (0, matroska_utils_1.matroskaToHex)(matroskaElements.Segment).byteLength -
@@ -1,6 +1,7 @@
1
+ import type { BytesAndOffset } from './matroska-utils';
1
2
  export type Cue = {
2
3
  time: number;
3
4
  clusterPosition: number;
4
5
  trackNumber: number;
5
6
  };
6
- export declare const createMatroskaCues: (cues: Cue[]) => import("./matroska-utils").BytesAndOffset;
7
+ export declare const createMatroskaCues: (cues: Cue[]) => BytesAndOffset | null;
@@ -3,6 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createMatroskaCues = void 0;
4
4
  const matroska_utils_1 = require("./matroska-utils");
5
5
  const createMatroskaCues = (cues) => {
6
+ if (cues.length === 0) {
7
+ return null;
8
+ }
6
9
  return (0, matroska_utils_1.makeMatroskaBytes)({
7
10
  type: 'Cues',
8
11
  minVintWidth: null,
@@ -17,12 +17,12 @@ const makeMatroskaInfo = ({ timescale }) => {
17
17
  },
18
18
  {
19
19
  type: 'MuxingApp',
20
- value: '@remotion/media-parser',
20
+ value: '@remotion/webcodecs',
21
21
  minVintWidth: null,
22
22
  },
23
23
  {
24
24
  type: 'WritingApp',
25
- value: '@remotion/media-parser',
25
+ value: '@remotion/webcodecs',
26
26
  minVintWidth: null,
27
27
  },
28
28
  (0, make_duration_with_padding_1.makeDurationWithPadding)(0),
@@ -112,11 +112,6 @@ const makeMatroskaAudioTrackEntryBytes = ({ trackNumber, codec, numberOfChannels
112
112
  },
113
113
  minVintWidth: null,
114
114
  },
115
- {
116
- type: 'TrackUID',
117
- value: '0x188FEB95C8EFABA',
118
- minVintWidth: null,
119
- },
120
115
  {
121
116
  type: 'TrackType',
122
117
  value: {
@@ -184,32 +179,11 @@ const makeMatroskaVideoTrackEntryBytes = ({ color, width, height, trackNumber, c
184
179
  },
185
180
  minVintWidth: null,
186
181
  },
187
- {
188
- type: 'TrackUID',
189
- value: '0xab2171012bb9020a',
190
- minVintWidth: null,
191
- },
192
- {
193
- type: 'FlagLacing',
194
- value: {
195
- value: 0,
196
- byteLength: null,
197
- },
198
- minVintWidth: null,
199
- },
200
182
  {
201
183
  type: 'Language',
202
184
  value: 'und',
203
185
  minVintWidth: null,
204
186
  },
205
- {
206
- type: 'FlagDefault',
207
- value: {
208
- value: 0,
209
- byteLength: null,
210
- },
211
- minVintWidth: null,
212
- },
213
187
  {
214
188
  type: 'CodecID',
215
189
  value: makeVideoCodecId(codec),
@@ -16,7 +16,7 @@ function putUintDynamic(number, minimumLength) {
16
16
  throw new Error('This function is designed for non-negative integers only.');
17
17
  }
18
18
  // Calculate the minimum number of bytes needed to store the integer
19
- const length = Math.max(minimumLength ?? 0, Math.ceil(Math.log2(number + 1) / 8));
19
+ const length = Math.max(minimumLength ?? 1, Math.ceil(Math.log2(number + 1) / 8));
20
20
  const bytes = new Uint8Array(length);
21
21
  for (let i = 0; i < length; i++) {
22
22
  // Extract each byte from the number
@@ -915,7 +915,7 @@ var canCopyAudioTrack = ({
915
915
  return inputCodec === "opus";
916
916
  }
917
917
  if (outputContainer === "mp4") {
918
- return inputCodec === "aac" && (inputContainer === "mp4" || inputContainer === "avi");
918
+ return inputCodec === "aac" && (inputContainer === "mp4" || inputContainer === "avi" || inputContainer === "m3u8");
919
919
  }
920
920
  if (outputContainer === "wav") {
921
921
  return false;
@@ -947,7 +947,7 @@ var canCopyVideoTrack = ({
947
947
  return inputTrack.codecWithoutConfig === "vp8" || inputTrack.codecWithoutConfig === "vp9";
948
948
  }
949
949
  if (outputContainer === "mp4") {
950
- return (inputTrack.codecWithoutConfig === "h264" || inputTrack.codecWithoutConfig === "h265") && (inputContainer === "mp4" || inputContainer === "avi");
950
+ return (inputTrack.codecWithoutConfig === "h264" || inputTrack.codecWithoutConfig === "h265") && (inputContainer === "mp4" || inputContainer === "avi" || inputContainer === "m3u8" && inputTrack.m3uStreamFormat === "mp4");
951
951
  }
952
952
  if (outputContainer === "wav") {
953
953
  return false;
@@ -2393,7 +2393,7 @@ function putUintDynamic(number, minimumLength) {
2393
2393
  if (number < 0) {
2394
2394
  throw new Error("This function is designed for non-negative integers only.");
2395
2395
  }
2396
- const length = Math.max(minimumLength ?? 0, Math.ceil(Math.log2(number + 1) / 8));
2396
+ const length = Math.max(minimumLength ?? 1, Math.ceil(Math.log2(number + 1) / 8));
2397
2397
  const bytes = new Uint8Array(length);
2398
2398
  for (let i = 0;i < length; i++) {
2399
2399
  bytes[length - 1 - i] = number >> 8 * i & 255;
@@ -3971,6 +3971,9 @@ var makeDurationWithPadding = (newDuration) => {
3971
3971
 
3972
3972
  // src/create/matroska/matroska-cues.ts
3973
3973
  var createMatroskaCues = (cues) => {
3974
+ if (cues.length === 0) {
3975
+ return null;
3976
+ }
3974
3977
  return makeMatroskaBytes({
3975
3978
  type: "Cues",
3976
3979
  minVintWidth: null,
@@ -4093,12 +4096,12 @@ var makeMatroskaInfo = ({ timescale }) => {
4093
4096
  },
4094
4097
  {
4095
4098
  type: "MuxingApp",
4096
- value: "@remotion/media-parser",
4099
+ value: "@remotion/webcodecs",
4097
4100
  minVintWidth: null
4098
4101
  },
4099
4102
  {
4100
4103
  type: "WritingApp",
4101
- value: "@remotion/media-parser",
4104
+ value: "@remotion/webcodecs",
4102
4105
  minVintWidth: null
4103
4106
  },
4104
4107
  makeDurationWithPadding(0)
@@ -4317,11 +4320,6 @@ var makeMatroskaAudioTrackEntryBytes = ({
4317
4320
  },
4318
4321
  minVintWidth: null
4319
4322
  },
4320
- {
4321
- type: "TrackUID",
4322
- value: "0x188FEB95C8EFABA",
4323
- minVintWidth: null
4324
- },
4325
4323
  {
4326
4324
  type: "TrackType",
4327
4325
  value: {
@@ -4393,32 +4391,11 @@ var makeMatroskaVideoTrackEntryBytes = ({
4393
4391
  },
4394
4392
  minVintWidth: null
4395
4393
  },
4396
- {
4397
- type: "TrackUID",
4398
- value: "0xab2171012bb9020a",
4399
- minVintWidth: null
4400
- },
4401
- {
4402
- type: "FlagLacing",
4403
- value: {
4404
- value: 0,
4405
- byteLength: null
4406
- },
4407
- minVintWidth: null
4408
- },
4409
4394
  {
4410
4395
  type: "Language",
4411
4396
  value: "und",
4412
4397
  minVintWidth: null
4413
4398
  },
4414
- {
4415
- type: "FlagDefault",
4416
- value: {
4417
- value: 0,
4418
- byteLength: null
4419
- },
4420
- minVintWidth: null
4421
- },
4422
4399
  {
4423
4400
  type: "CodecID",
4424
4401
  value: makeVideoCodecId(codec),
@@ -4628,12 +4605,15 @@ var createMatroskaMedia = async ({
4628
4605
  async waitForFinish() {
4629
4606
  await Promise.all(waitForFinishPromises.map((p) => p()));
4630
4607
  await operationProm.current;
4631
- seeks.push({
4632
- hexString: matroskaElements.Cues,
4633
- byte: w.getWrittenByteCount() - seekHeadOffset
4634
- });
4608
+ const cuesBytes = createMatroskaCues(cues);
4609
+ if (cuesBytes) {
4610
+ seeks.push({
4611
+ hexString: matroskaElements.Cues,
4612
+ byte: w.getWrittenByteCount() - seekHeadOffset
4613
+ });
4614
+ await w.write(cuesBytes.bytes);
4615
+ }
4635
4616
  await updateSeekWrite();
4636
- await w.write(createMatroskaCues(cues).bytes);
4637
4617
  const segmentSize = w.getWrittenByteCount() - segmentOffset - matroskaToHex(matroskaElements.Segment).byteLength - MATROSKA_SEGMENT_MIN_VINT_WIDTH;
4638
4618
  await updateSegmentSize(segmentSize);
4639
4619
  await w.finish();
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const bun_test_1 = require("bun:test");
4
+ const matroska_utils_1 = require("../create/matroska/matroska-utils");
5
+ (0, bun_test_1.test)('should serialize with correct byte length', () => {
6
+ const withInheritedWidth = (0, matroska_utils_1.makeMatroskaBytes)({
7
+ type: 'Timestamp',
8
+ minVintWidth: null,
9
+ value: {
10
+ value: 0,
11
+ byteLength: null,
12
+ },
13
+ });
14
+ const withFixedWidth = (0, matroska_utils_1.makeMatroskaBytes)({
15
+ type: 'Timestamp',
16
+ minVintWidth: null,
17
+ value: {
18
+ value: 0,
19
+ byteLength: 1,
20
+ },
21
+ });
22
+ (0, bun_test_1.expect)(withFixedWidth.bytes).toEqual(withInheritedWidth.bytes);
23
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remotion/webcodecs",
3
- "version": "4.0.273",
3
+ "version": "4.0.275",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "module": "dist/esm/index.mjs",
@@ -17,15 +17,15 @@
17
17
  "author": "Jonny Burger <jonny@remotion.dev>",
18
18
  "license": "Remotion License (See https://remotion.dev/docs/webcodecs#license)",
19
19
  "dependencies": {
20
- "@remotion/media-parser": "4.0.273",
21
- "@remotion/licensing": "4.0.273"
20
+ "@remotion/media-parser": "4.0.275",
21
+ "@remotion/licensing": "4.0.275"
22
22
  },
23
23
  "peerDependencies": {},
24
24
  "devDependencies": {
25
25
  "@types/dom-webcodecs": "0.1.11",
26
26
  "eslint": "9.19.0",
27
- "@remotion/eslint-config-internal": "4.0.273",
28
- "@remotion/example-videos": "4.0.273"
27
+ "@remotion/example-videos": "4.0.275",
28
+ "@remotion/eslint-config-internal": "4.0.275"
29
29
  },
30
30
  "keywords": [],
31
31
  "publishConfig": {