@remotion/webcodecs 4.0.231 → 4.0.232

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.
Files changed (48) hide show
  1. package/dist/audio-decoder.js +6 -0
  2. package/dist/audio-encoder-config.d.ts +4 -1
  3. package/dist/audio-encoder-config.js +6 -0
  4. package/dist/audio-encoder.d.ts +4 -3
  5. package/dist/audio-encoder.js +4 -0
  6. package/dist/can-copy-audio-track.d.ts +1 -1
  7. package/dist/can-copy-audio-track.js +3 -0
  8. package/dist/can-copy-video-track.d.ts +1 -1
  9. package/dist/can-copy-video-track.js +4 -1
  10. package/dist/can-reencode-audio-track.d.ts +1 -1
  11. package/dist/can-reencode-audio-track.js +3 -0
  12. package/dist/can-reencode-video-track.d.ts +1 -1
  13. package/dist/codec-id.d.ts +2 -2
  14. package/dist/codec-id.js +8 -2
  15. package/dist/convert-media.d.ts +3 -1
  16. package/dist/convert-media.js +4 -5
  17. package/dist/convert-to-correct-videoframe.d.ts +1 -1
  18. package/dist/convert-to-correct-videoframe.js +4 -0
  19. package/dist/default-on-video-track-handler.js +4 -0
  20. package/dist/esm/index.mjs +134 -45
  21. package/dist/generate-output-filename.d.ts +1 -1
  22. package/dist/get-available-audio-codecs.d.ts +7 -0
  23. package/dist/get-available-audio-codecs.js +18 -0
  24. package/dist/get-available-containers.d.ts +4 -0
  25. package/dist/get-available-containers.js +8 -0
  26. package/dist/get-available-video-codecs.d.ts +7 -0
  27. package/dist/get-available-video-codecs.js +18 -0
  28. package/dist/get-default-audio-codec.d.ts +2 -1
  29. package/dist/get-default-audio-codec.js +3 -0
  30. package/dist/get-default-video-codec.d.ts +3 -2
  31. package/dist/get-default-video-codec.js +7 -1
  32. package/dist/index.d.ts +3 -1
  33. package/dist/index.js +7 -5
  34. package/dist/io-manager/io-synchronizer.js +12 -6
  35. package/dist/on-audio-track-handler.d.ts +2 -1
  36. package/dist/on-audio-track.d.ts +2 -1
  37. package/dist/on-audio-track.js +3 -1
  38. package/dist/on-frame.d.ts +1 -1
  39. package/dist/on-frame.js +0 -6
  40. package/dist/on-video-track-handler.d.ts +2 -1
  41. package/dist/on-video-track.d.ts +2 -1
  42. package/dist/select-container-creator.d.ts +2 -0
  43. package/dist/select-container-creator.js +17 -0
  44. package/dist/video-encoder-config.d.ts +1 -1
  45. package/dist/video-encoder.d.ts +1 -1
  46. package/dist/wav-audio-encoder.d.ts +2 -0
  47. package/dist/wav-audio-encoder.js +26 -0
  48. package/package.json +3 -3
@@ -62,11 +62,17 @@ const createAudioDecoder = ({ onFrame, onError, signal, config, logLevel, }) =>
62
62
  let queue = Promise.resolve();
63
63
  return {
64
64
  processSample: (sample) => {
65
+ // In example.avi, we have samples with 0 data
66
+ // Chrome fails on these
67
+ if (sample.data.length === 0) {
68
+ return queue;
69
+ }
65
70
  queue = queue.then(() => processSample(sample));
66
71
  return queue;
67
72
  },
68
73
  waitForFinish: async () => {
69
74
  await audioDecoder.flush();
75
+ await queue;
70
76
  await ioSynchronizer.waitForFinish();
71
77
  await outputQueue;
72
78
  },
@@ -1 +1,4 @@
1
- export declare const getAudioEncoderConfig: (config: AudioEncoderConfig) => Promise<AudioEncoderConfig | null>;
1
+ import type { ConvertMediaAudioCodec } from './get-available-audio-codecs';
2
+ export declare const getAudioEncoderConfig: (config: AudioEncoderConfig & {
3
+ codec: ConvertMediaAudioCodec;
4
+ }) => Promise<AudioEncoderConfig | null>;
@@ -8,6 +8,9 @@ const getCodecString = (audioCodec) => {
8
8
  if (audioCodec === 'aac') {
9
9
  return 'mp4a.40.02';
10
10
  }
11
+ if (audioCodec === 'wav') {
12
+ return 'wav-should-not-to-into-audio-encoder';
13
+ }
11
14
  throw new Error(`Unsupported audio codec: ${audioCodec}`);
12
15
  };
13
16
  const getAudioEncoderConfig = async (config) => {
@@ -15,6 +18,9 @@ const getAudioEncoderConfig = async (config) => {
15
18
  ...config,
16
19
  codec: getCodecString(config.codec),
17
20
  };
21
+ if (config.codec === 'wav') {
22
+ return actualConfig;
23
+ }
18
24
  if (typeof AudioEncoder === 'undefined') {
19
25
  return null;
20
26
  }
@@ -1,12 +1,12 @@
1
1
  import type { LogLevel } from '@remotion/media-parser';
2
- import type { ConvertMediaAudioCodec } from './codec-id';
2
+ import type { ConvertMediaAudioCodec } from './get-available-audio-codecs';
3
3
  export type WebCodecsAudioEncoder = {
4
4
  encodeFrame: (audioData: AudioData) => Promise<void>;
5
5
  waitForFinish: () => Promise<void>;
6
6
  close: () => void;
7
7
  flush: () => Promise<void>;
8
8
  };
9
- export declare const createAudioEncoder: ({ onChunk, onError, codec, signal, config: audioEncoderConfig, logLevel, onNewAudioSampleRate, }: {
9
+ export type AudioEncoderInit = {
10
10
  onChunk: (chunk: EncodedAudioChunk) => Promise<void>;
11
11
  onError: (error: DOMException) => void;
12
12
  codec: ConvertMediaAudioCodec;
@@ -14,4 +14,5 @@ export declare const createAudioEncoder: ({ onChunk, onError, codec, signal, con
14
14
  config: AudioEncoderConfig;
15
15
  logLevel: LogLevel;
16
16
  onNewAudioSampleRate: (sampleRate: number) => void;
17
- }) => WebCodecsAudioEncoder;
17
+ };
18
+ export declare const createAudioEncoder: ({ onChunk, onError, codec, signal, config: audioEncoderConfig, logLevel, onNewAudioSampleRate, }: AudioEncoderInit) => WebCodecsAudioEncoder;
@@ -2,10 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createAudioEncoder = void 0;
4
4
  const io_synchronizer_1 = require("./io-manager/io-synchronizer");
5
+ const wav_audio_encoder_1 = require("./wav-audio-encoder");
5
6
  const createAudioEncoder = ({ onChunk, onError, codec, signal, config: audioEncoderConfig, logLevel, onNewAudioSampleRate, }) => {
6
7
  if (signal.aborted) {
7
8
  throw new Error('Not creating audio encoder, already aborted');
8
9
  }
10
+ if (codec === 'wav') {
11
+ return (0, wav_audio_encoder_1.getWaveAudioEncoder)({ onChunk, signal });
12
+ }
9
13
  const ioSynchronizer = (0, io_synchronizer_1.makeIoSynchronizer)(logLevel, 'Audio encoder');
10
14
  let prom = Promise.resolve();
11
15
  const encoder = new AudioEncoder({
@@ -1,5 +1,5 @@
1
1
  import type { MediaParserAudioCodec } from '@remotion/media-parser';
2
- import type { ConvertMediaContainer } from './codec-id';
2
+ import type { ConvertMediaContainer } from './get-available-containers';
3
3
  export declare const canCopyAudioTrack: ({ inputCodec, container, }: {
4
4
  inputCodec: MediaParserAudioCodec;
5
5
  container: ConvertMediaContainer;
@@ -8,6 +8,9 @@ const canCopyAudioTrack = ({ inputCodec, container, }) => {
8
8
  if (container === 'mp4') {
9
9
  return inputCodec === 'aac';
10
10
  }
11
+ if (container === 'wav') {
12
+ return false;
13
+ }
11
14
  throw new Error(`Unhandled codec: ${container}`);
12
15
  };
13
16
  exports.canCopyAudioTrack = canCopyAudioTrack;
@@ -1,5 +1,5 @@
1
1
  import type { MediaParserVideoCodec } from '@remotion/media-parser';
2
- import type { ConvertMediaContainer } from './codec-id';
2
+ import type { ConvertMediaContainer } from './get-available-containers';
3
3
  export declare const canCopyVideoTrack: ({ inputCodec, container, }: {
4
4
  inputCodec: MediaParserVideoCodec;
5
5
  container: ConvertMediaContainer;
@@ -6,7 +6,10 @@ const canCopyVideoTrack = ({ inputCodec, container, }) => {
6
6
  return inputCodec === 'vp8' || inputCodec === 'vp9';
7
7
  }
8
8
  if (container === 'mp4') {
9
- return inputCodec === 'h264' || inputCodec === 'h265';
9
+ return inputCodec === 'h264';
10
+ }
11
+ if (container === 'wav') {
12
+ return false;
10
13
  }
11
14
  throw new Error(`Unhandled codec: ${container}`);
12
15
  };
@@ -1,5 +1,5 @@
1
1
  import type { AudioTrack } from '@remotion/media-parser';
2
- import type { ConvertMediaAudioCodec } from './codec-id';
2
+ import type { ConvertMediaAudioCodec } from './get-available-audio-codecs';
3
3
  export declare const canReencodeAudioTrack: ({ track, audioCodec, bitrate, }: {
4
4
  track: AudioTrack;
5
5
  audioCodec: ConvertMediaAudioCodec;
@@ -5,6 +5,9 @@ const audio_decoder_config_1 = require("./audio-decoder-config");
5
5
  const audio_encoder_config_1 = require("./audio-encoder-config");
6
6
  const canReencodeAudioTrack = async ({ track, audioCodec, bitrate, }) => {
7
7
  const audioDecoderConfig = await (0, audio_decoder_config_1.getAudioDecoderConfig)(track);
8
+ if (audioCodec === 'wav' && audioDecoderConfig) {
9
+ return true;
10
+ }
8
11
  const audioEncoderConfig = await (0, audio_encoder_config_1.getAudioEncoderConfig)({
9
12
  codec: audioCodec,
10
13
  numberOfChannels: track.numberOfChannels,
@@ -1,5 +1,5 @@
1
1
  import type { VideoTrack } from '@remotion/media-parser';
2
- import type { ConvertMediaVideoCodec } from './codec-id';
2
+ import type { ConvertMediaVideoCodec } from './get-available-video-codecs';
3
3
  export declare const canReencodeVideoTrack: ({ videoCodec, track, }: {
4
4
  videoCodec: ConvertMediaVideoCodec;
5
5
  track: VideoTrack;
@@ -1,10 +1,10 @@
1
- declare const availableContainers: readonly ["webm", "mp4"];
1
+ declare const availableContainers: readonly ["webm", "mp4", "wav"];
2
2
  export type ConvertMediaContainer = (typeof availableContainers)[number];
3
3
  export declare const getAvailableContainers: () => readonly ConvertMediaContainer[];
4
4
  declare const availableVideoCodecs: readonly ["vp8", "vp9", "h264"];
5
5
  export type ConvertMediaVideoCodec = (typeof availableVideoCodecs)[number];
6
6
  export declare const getAvailableVideoCodecs: (container: ConvertMediaContainer) => ConvertMediaVideoCodec[];
7
- declare const availableAudioCodecs: readonly ["opus", "aac"];
7
+ declare const availableAudioCodecs: readonly ["opus", "aac", "wav"];
8
8
  export declare const getAvailableAudioCodecs: (container: ConvertMediaContainer) => ConvertMediaAudioCodec[];
9
9
  export type ConvertMediaAudioCodec = (typeof availableAudioCodecs)[number];
10
10
  export {};
package/dist/codec-id.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getAvailableAudioCodecs = exports.getAvailableVideoCodecs = exports.getAvailableContainers = void 0;
4
- const availableContainers = ['webm', 'mp4'];
4
+ const availableContainers = ['webm', 'mp4', 'wav'];
5
5
  const getAvailableContainers = () => {
6
6
  return availableContainers;
7
7
  };
@@ -15,11 +15,14 @@ const getAvailableVideoCodecs = (container) => {
15
15
  if (container === 'webm') {
16
16
  return ['vp8', 'vp9'];
17
17
  }
18
+ if (container === 'wav') {
19
+ return [];
20
+ }
18
21
  throw new Error(`Unsupported container: ${container}`);
19
22
  };
20
23
  exports.getAvailableVideoCodecs = getAvailableVideoCodecs;
21
24
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
22
- const availableAudioCodecs = ['opus', 'aac'];
25
+ const availableAudioCodecs = ['opus', 'aac', 'wav'];
23
26
  const getAvailableAudioCodecs = (container) => {
24
27
  if (container === 'mp4') {
25
28
  return ['aac'];
@@ -27,6 +30,9 @@ const getAvailableAudioCodecs = (container) => {
27
30
  if (container === 'webm') {
28
31
  return ['opus'];
29
32
  }
33
+ if (container === 'wav') {
34
+ return ['wav'];
35
+ }
30
36
  throw new Error(`Unsupported container: ${container}`);
31
37
  };
32
38
  exports.getAvailableAudioCodecs = getAvailableAudioCodecs;
@@ -3,7 +3,9 @@
3
3
  * For licensing, see: https://remotion.dev/docs/webcodecs#license
4
4
  */
5
5
  import type { LogLevel, Options, ParseMediaDynamicOptions, ParseMediaFields, ParseMediaOptions, VideoTrack, WriterInterface } from '@remotion/media-parser';
6
- import type { ConvertMediaAudioCodec, ConvertMediaContainer, ConvertMediaVideoCodec } from './codec-id';
6
+ import type { ConvertMediaAudioCodec } from './get-available-audio-codecs';
7
+ import type { ConvertMediaContainer } from './get-available-containers';
8
+ import type { ConvertMediaVideoCodec } from './get-available-video-codecs';
7
9
  import { type ConvertMediaOnAudioTrackHandler } from './on-audio-track-handler';
8
10
  import { type ConvertMediaOnVideoTrackHandler } from './on-video-track-handler';
9
11
  export type ConvertMediaProgress = {
@@ -15,6 +15,7 @@ const error_cause_1 = __importDefault(require("./error-cause"));
15
15
  const generate_output_filename_1 = require("./generate-output-filename");
16
16
  const on_audio_track_1 = require("./on-audio-track");
17
17
  const on_video_track_1 = require("./on-video-track");
18
+ const select_container_creator_1 = require("./select-container-creator");
18
19
  const throttled_state_update_1 = require("./throttled-state-update");
19
20
  const with_resolvers_1 = require("./with-resolvers");
20
21
  const convertMedia = async function ({ src, onVideoFrame, onProgress: onProgressDoNotCallDirectly, audioCodec, container, videoCodec, signal: userPassedAbortSignal, onAudioTrack: userAudioResolver, onVideoTrack: userVideoResolver, reader, fields, logLevel = 'info', writer, progressIntervalInMs, ...more }) {
@@ -22,8 +23,8 @@ const convertMedia = async function ({ src, onVideoFrame, onProgress: onProgress
22
23
  if (userPassedAbortSignal === null || userPassedAbortSignal === void 0 ? void 0 : userPassedAbortSignal.aborted) {
23
24
  return Promise.reject(new error_cause_1.default('Aborted'));
24
25
  }
25
- if (container !== 'webm' && container !== 'mp4') {
26
- return Promise.reject(new TypeError('Only `to: "webm"` and `to: "mp4"` is supported currently'));
26
+ if (container !== 'webm' && container !== 'mp4' && container !== 'wav') {
27
+ return Promise.reject(new TypeError('Only `to: "webm"`, `to: "mp4"` and `to: "wav"` is supported currently'));
27
28
  }
28
29
  if (videoCodec && videoCodec !== 'vp8' && videoCodec !== 'vp9') {
29
30
  return Promise.reject(new TypeError('Only `videoCodec: "vp8"` and `videoCodec: "vp9"` are supported currently'));
@@ -40,9 +41,7 @@ const convertMedia = async function ({ src, onVideoFrame, onProgress: onProgress
40
41
  abortConversion(new error_cause_1.default('Conversion aborted by user'));
41
42
  };
42
43
  userPassedAbortSignal === null || userPassedAbortSignal === void 0 ? void 0 : userPassedAbortSignal.addEventListener('abort', onUserAbort);
43
- const creator = container === 'webm'
44
- ? media_parser_1.MediaParserInternals.createMatroskaMedia
45
- : media_parser_1.MediaParserInternals.createIsoBaseMedia;
44
+ const creator = (0, select_container_creator_1.selectContainerCreator)(container);
46
45
  const throttledState = (0, throttled_state_update_1.throttledStateUpdate)({
47
46
  updateFn: onProgressDoNotCallDirectly !== null && onProgressDoNotCallDirectly !== void 0 ? onProgressDoNotCallDirectly : null,
48
47
  everyMilliseconds: progressIntervalInMs !== null && progressIntervalInMs !== void 0 ? progressIntervalInMs : 100,
@@ -1,4 +1,4 @@
1
- import type { ConvertMediaVideoCodec } from './codec-id';
1
+ import type { ConvertMediaVideoCodec } from './get-available-video-codecs';
2
2
  export declare const needsToCorrectVideoFrame: ({ videoFrame, outputCodec, }: {
3
3
  videoFrame: VideoFrame;
4
4
  outputCodec: ConvertMediaVideoCodec;
@@ -3,6 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.convertToCorrectVideoFrame = exports.needsToCorrectVideoFrame = void 0;
4
4
  const browser_quirks_1 = require("./browser-quirks");
5
5
  const needsToCorrectVideoFrame = ({ videoFrame, outputCodec, }) => {
6
+ // On Chrome when dropping a vertical iPhone video
7
+ if (videoFrame.format === null) {
8
+ return true;
9
+ }
6
10
  return (0, browser_quirks_1.isFirefox)() && videoFrame.format === 'BGRX' && outputCodec === 'h264';
7
11
  };
8
12
  exports.needsToCorrectVideoFrame = needsToCorrectVideoFrame;
@@ -15,6 +15,10 @@ const defaultOnVideoTrackHandler = async ({ track, defaultVideoCodec, logLevel,
15
15
  return Promise.resolve({ type: 'copy' });
16
16
  }
17
17
  const videoCodec = defaultVideoCodec !== null && defaultVideoCodec !== void 0 ? defaultVideoCodec : (0, get_default_video_codec_1.getDefaultVideoCodec)({ container });
18
+ if (videoCodec === null) {
19
+ media_parser_1.MediaParserInternals.Log.verbose(logLevel, `Track ${track.trackId} (video): No default video codec, therefore dropping`);
20
+ return Promise.resolve({ type: 'drop' });
21
+ }
18
22
  const canReencode = await (0, can_reencode_video_track_1.canReencodeVideoTrack)({
19
23
  videoCodec,
20
24
  track,
@@ -129,12 +129,18 @@ var makeIoSynchronizer = (logLevel, label) => {
129
129
  _unprocessed,
130
130
  unemitted
131
131
  }) => {
132
- while (getUnemittedItems() > unemitted) {
133
- await waitForOutput();
134
- }
135
- while (getUnprocessed() > _unprocessed) {
136
- await waitForProcessed();
137
- }
132
+ await Promise.all([
133
+ async () => {
134
+ while (getUnemittedItems() > unemitted) {
135
+ await waitForOutput();
136
+ }
137
+ },
138
+ async () => {
139
+ while (getUnprocessed() > _unprocessed) {
140
+ await waitForProcessed();
141
+ }
142
+ }
143
+ ]);
138
144
  };
139
145
  const waitForFinish = async () => {
140
146
  await waitFor({ _unprocessed: 0, unemitted: 0 });
@@ -215,11 +221,15 @@ var createAudioDecoder = ({
215
221
  let queue = Promise.resolve();
216
222
  return {
217
223
  processSample: (sample) => {
224
+ if (sample.data.length === 0) {
225
+ return queue;
226
+ }
218
227
  queue = queue.then(() => processSample(sample));
219
228
  return queue;
220
229
  },
221
230
  waitForFinish: async () => {
222
231
  await audioDecoder.flush();
232
+ await queue;
223
233
  await ioSynchronizer.waitForFinish();
224
234
  await outputQueue;
225
235
  },
@@ -229,6 +239,33 @@ var createAudioDecoder = ({
229
239
  }
230
240
  };
231
241
  };
242
+ // src/wav-audio-encoder.ts
243
+ var getWaveAudioEncoder = ({
244
+ onChunk,
245
+ signal
246
+ }) => {
247
+ return {
248
+ close: () => {
249
+ return Promise.resolve();
250
+ },
251
+ encodeFrame: (audioData) => {
252
+ if (signal.aborted) {
253
+ return Promise.resolve();
254
+ }
255
+ const chunk = {
256
+ timestamp: audioData.timestamp,
257
+ duration: audioData.duration,
258
+ type: "key",
259
+ copyTo: (destination) => audioData.copyTo(destination, { planeIndex: 0, format: "s16" }),
260
+ byteLength: audioData.allocationSize({ planeIndex: 0, format: "s16" })
261
+ };
262
+ return onChunk(chunk);
263
+ },
264
+ flush: () => Promise.resolve(),
265
+ waitForFinish: () => Promise.resolve()
266
+ };
267
+ };
268
+
232
269
  // src/audio-encoder.ts
233
270
  var createAudioEncoder = ({
234
271
  onChunk,
@@ -242,6 +279,9 @@ var createAudioEncoder = ({
242
279
  if (signal.aborted) {
243
280
  throw new Error("Not creating audio encoder, already aborted");
244
281
  }
282
+ if (codec === "wav") {
283
+ return getWaveAudioEncoder({ onChunk, signal });
284
+ }
245
285
  const ioSynchronizer = makeIoSynchronizer(logLevel, "Audio encoder");
246
286
  let prom = Promise.resolve();
247
287
  const encoder = new AudioEncoder({
@@ -328,6 +368,9 @@ var canCopyAudioTrack = ({
328
368
  if (container === "mp4") {
329
369
  return inputCodec === "aac";
330
370
  }
371
+ if (container === "wav") {
372
+ return false;
373
+ }
331
374
  throw new Error(`Unhandled codec: ${container}`);
332
375
  };
333
376
  // src/can-copy-video-track.ts
@@ -339,7 +382,10 @@ var canCopyVideoTrack = ({
339
382
  return inputCodec === "vp8" || inputCodec === "vp9";
340
383
  }
341
384
  if (container === "mp4") {
342
- return inputCodec === "h264" || inputCodec === "h265";
385
+ return inputCodec === "h264";
386
+ }
387
+ if (container === "wav") {
388
+ return false;
343
389
  }
344
390
  throw new Error(`Unhandled codec: ${container}`);
345
391
  };
@@ -365,6 +411,9 @@ var getCodecString = (audioCodec) => {
365
411
  if (audioCodec === "aac") {
366
412
  return "mp4a.40.02";
367
413
  }
414
+ if (audioCodec === "wav") {
415
+ return "wav-should-not-to-into-audio-encoder";
416
+ }
368
417
  throw new Error(`Unsupported audio codec: ${audioCodec}`);
369
418
  };
370
419
  var getAudioEncoderConfig = async (config) => {
@@ -372,6 +421,9 @@ var getAudioEncoderConfig = async (config) => {
372
421
  ...config,
373
422
  codec: getCodecString(config.codec)
374
423
  };
424
+ if (config.codec === "wav") {
425
+ return actualConfig;
426
+ }
375
427
  if (typeof AudioEncoder === "undefined") {
376
428
  return null;
377
429
  }
@@ -388,6 +440,9 @@ var canReencodeAudioTrack = async ({
388
440
  bitrate
389
441
  }) => {
390
442
  const audioDecoderConfig = await getAudioDecoderConfig(track);
443
+ if (audioCodec === "wav" && audioDecoderConfig) {
444
+ return true;
445
+ }
391
446
  const audioEncoderConfig = await getAudioEncoderConfig({
392
447
  codec: audioCodec,
393
448
  numberOfChannels: track.numberOfChannels,
@@ -508,34 +563,8 @@ var canReencodeVideoTrack = async ({
508
563
  const videoDecoderConfig = await getVideoDecoderConfigWithHardwareAcceleration(track);
509
564
  return Boolean(videoDecoderConfig && videoEncoderConfig);
510
565
  };
511
- // src/codec-id.ts
512
- var availableContainers = ["webm", "mp4"];
513
- var getAvailableContainers = () => {
514
- return availableContainers;
515
- };
516
- var getAvailableVideoCodecs = (container) => {
517
- if (container === "mp4") {
518
- return ["h264"];
519
- }
520
- if (container === "webm") {
521
- return ["vp8", "vp9"];
522
- }
523
- throw new Error(`Unsupported container: ${container}`);
524
- };
525
- var getAvailableAudioCodecs = (container) => {
526
- if (container === "mp4") {
527
- return ["aac"];
528
- }
529
- if (container === "webm") {
530
- return ["opus"];
531
- }
532
- throw new Error(`Unsupported container: ${container}`);
533
- };
534
566
  // src/convert-media.ts
535
- import {
536
- MediaParserInternals as MediaParserInternals4,
537
- parseMedia
538
- } from "@remotion/media-parser";
567
+ import { parseMedia } from "@remotion/media-parser";
539
568
 
540
569
  // src/auto-select-writer.ts
541
570
  import { bufferWriter } from "@remotion/media-parser/buffer";
@@ -604,6 +633,9 @@ var getDefaultAudioCodec = ({
604
633
  if (container === "mp4") {
605
634
  return "aac";
606
635
  }
636
+ if (container === "wav") {
637
+ return "wav";
638
+ }
607
639
  throw new Error(`Unhandled container: ${container}`);
608
640
  };
609
641
 
@@ -714,7 +746,7 @@ var makeAudioTrackHandler = ({
714
746
  const codecPrivate = audioOperation.audioCodec === "aac" ? new Uint8Array([17, 144]) : null;
715
747
  const { trackNumber } = await state.addTrack({
716
748
  type: "audio",
717
- codec: audioOperation.audioCodec,
749
+ codec: audioOperation.audioCodec === "wav" ? "pcm-s16" : audioOperation.audioCodec,
718
750
  numberOfChannels: track.numberOfChannels,
719
751
  sampleRate: track.sampleRate,
720
752
  codecPrivate,
@@ -795,7 +827,13 @@ var getDefaultVideoCodec = ({
795
827
  if (container === "webm") {
796
828
  return "vp8";
797
829
  }
798
- throw new Error(`Unhandled container: ${container} satisfies never`);
830
+ if (container === "mp4") {
831
+ return "h264";
832
+ }
833
+ if (container === "wav") {
834
+ return null;
835
+ }
836
+ throw new Error(`Unhandled container: ${container}`);
799
837
  };
800
838
 
801
839
  // src/default-on-video-track-handler.ts
@@ -814,6 +852,10 @@ var defaultOnVideoTrackHandler = async ({
814
852
  return Promise.resolve({ type: "copy" });
815
853
  }
816
854
  const videoCodec = defaultVideoCodec ?? getDefaultVideoCodec({ container });
855
+ if (videoCodec === null) {
856
+ MediaParserInternals3.Log.verbose(logLevel, `Track ${track.trackId} (video): No default video codec, therefore dropping`);
857
+ return Promise.resolve({ type: "drop" });
858
+ }
817
859
  const canReencode = await canReencodeVideoTrack({
818
860
  videoCodec,
819
861
  track
@@ -831,6 +873,9 @@ var needsToCorrectVideoFrame = ({
831
873
  videoFrame,
832
874
  outputCodec
833
875
  }) => {
876
+ if (videoFrame.format === null) {
877
+ return true;
878
+ }
834
879
  return isFirefox() && videoFrame.format === "BGRX" && outputCodec === "h264";
835
880
  };
836
881
  var convertToCorrectVideoFrame = ({
@@ -865,12 +910,6 @@ var onFrame = async ({
865
910
  outputCodec
866
911
  }) => {
867
912
  const newFrame = onVideoFrame ? await onVideoFrame({ frame, track }) : frame;
868
- if (newFrame.codedHeight !== frame.displayHeight) {
869
- throw new Error(`Returned VideoFrame of track ${track.trackId} has different codedHeight (${newFrame.codedHeight}) than the input frame displayHeight (${frame.displayHeight})`);
870
- }
871
- if (newFrame.codedWidth !== frame.displayWidth) {
872
- throw new Error(`Returned VideoFrame of track ${track.trackId} has different codedWidth (${newFrame.codedWidth}) than the input frame displayWidth (${frame.displayWidth})`);
873
- }
874
913
  if (newFrame.displayWidth !== frame.displayWidth) {
875
914
  throw new Error(`Returned VideoFrame of track ${track.trackId} has different displayWidth (${newFrame.displayWidth}) than the input frame (${newFrame.displayHeight})`);
876
915
  }
@@ -1203,6 +1242,21 @@ var makeVideoTrackHandler = ({
1203
1242
  };
1204
1243
  };
1205
1244
 
1245
+ // src/select-container-creator.ts
1246
+ import { MediaParserInternals as MediaParserInternals4 } from "@remotion/media-parser";
1247
+ var selectContainerCreator = (container) => {
1248
+ if (container === "mp4") {
1249
+ return MediaParserInternals4.createIsoBaseMedia;
1250
+ }
1251
+ if (container === "wav") {
1252
+ return MediaParserInternals4.createWav;
1253
+ }
1254
+ if (container === "webm") {
1255
+ return MediaParserInternals4.createMatroskaMedia;
1256
+ }
1257
+ throw new Error(`Unsupported container: ${container}`);
1258
+ };
1259
+
1206
1260
  // src/throttled-state-update.ts
1207
1261
  var throttledStateUpdate = ({
1208
1262
  updateFn,
@@ -1276,8 +1330,8 @@ var convertMedia = async function({
1276
1330
  if (userPassedAbortSignal?.aborted) {
1277
1331
  return Promise.reject(new error_cause_default("Aborted"));
1278
1332
  }
1279
- if (container !== "webm" && container !== "mp4") {
1280
- return Promise.reject(new TypeError('Only `to: "webm"` and `to: "mp4"` is supported currently'));
1333
+ if (container !== "webm" && container !== "mp4" && container !== "wav") {
1334
+ return Promise.reject(new TypeError('Only `to: "webm"`, `to: "mp4"` and `to: "wav"` is supported currently'));
1281
1335
  }
1282
1336
  if (videoCodec && videoCodec !== "vp8" && videoCodec !== "vp9") {
1283
1337
  return Promise.reject(new TypeError('Only `videoCodec: "vp8"` and `videoCodec: "vp9"` are supported currently'));
@@ -1294,7 +1348,7 @@ var convertMedia = async function({
1294
1348
  abortConversion(new error_cause_default("Conversion aborted by user"));
1295
1349
  };
1296
1350
  userPassedAbortSignal?.addEventListener("abort", onUserAbort);
1297
- const creator = container === "webm" ? MediaParserInternals4.createMatroskaMedia : MediaParserInternals4.createIsoBaseMedia;
1351
+ const creator = selectContainerCreator(container);
1298
1352
  const throttledState = throttledStateUpdate({
1299
1353
  updateFn: onProgressDoNotCallDirectly ?? null,
1300
1354
  everyMilliseconds: progressIntervalInMs ?? 100,
@@ -1398,6 +1452,41 @@ var convertMedia = async function({
1398
1452
  userPassedAbortSignal?.removeEventListener("abort", onUserAbort);
1399
1453
  });
1400
1454
  };
1455
+ // src/get-available-audio-codecs.ts
1456
+ var getAvailableAudioCodecs = ({
1457
+ container
1458
+ }) => {
1459
+ if (container === "mp4") {
1460
+ return ["aac"];
1461
+ }
1462
+ if (container === "webm") {
1463
+ return ["opus"];
1464
+ }
1465
+ if (container === "wav") {
1466
+ return ["wav"];
1467
+ }
1468
+ throw new Error(`Unsupported container: ${container}`);
1469
+ };
1470
+ // src/get-available-containers.ts
1471
+ var availableContainers = ["webm", "mp4", "wav"];
1472
+ var getAvailableContainers = () => {
1473
+ return availableContainers;
1474
+ };
1475
+ // src/get-available-video-codecs.ts
1476
+ var getAvailableVideoCodecs = ({
1477
+ container
1478
+ }) => {
1479
+ if (container === "mp4") {
1480
+ return ["h264"];
1481
+ }
1482
+ if (container === "webm") {
1483
+ return ["vp8", "vp9"];
1484
+ }
1485
+ if (container === "wav") {
1486
+ return [];
1487
+ }
1488
+ throw new Error(`Unsupported container: ${container}`);
1489
+ };
1401
1490
  // src/index.ts
1402
1491
  setRemotionImported();
1403
1492
  export {
@@ -1,2 +1,2 @@
1
- import type { ConvertMediaContainer } from './codec-id';
1
+ import type { ConvertMediaContainer } from './get-available-containers';
2
2
  export declare const generateOutputFilename: (source: string | Blob, container: ConvertMediaContainer) => string;
@@ -0,0 +1,7 @@
1
+ import type { ConvertMediaContainer } from './get-available-containers';
2
+ declare const availableAudioCodecs: readonly ["opus", "aac", "wav"];
3
+ export declare const getAvailableAudioCodecs: ({ container, }: {
4
+ container: ConvertMediaContainer;
5
+ }) => ConvertMediaAudioCodec[];
6
+ export type ConvertMediaAudioCodec = (typeof availableAudioCodecs)[number];
7
+ export {};
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getAvailableAudioCodecs = void 0;
4
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
5
+ const availableAudioCodecs = ['opus', 'aac', 'wav'];
6
+ const getAvailableAudioCodecs = ({ container, }) => {
7
+ if (container === 'mp4') {
8
+ return ['aac'];
9
+ }
10
+ if (container === 'webm') {
11
+ return ['opus'];
12
+ }
13
+ if (container === 'wav') {
14
+ return ['wav'];
15
+ }
16
+ throw new Error(`Unsupported container: ${container}`);
17
+ };
18
+ exports.getAvailableAudioCodecs = getAvailableAudioCodecs;
@@ -0,0 +1,4 @@
1
+ declare const availableContainers: readonly ["webm", "mp4", "wav"];
2
+ export type ConvertMediaContainer = (typeof availableContainers)[number];
3
+ export declare const getAvailableContainers: () => readonly ConvertMediaContainer[];
4
+ export {};
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getAvailableContainers = void 0;
4
+ const availableContainers = ['webm', 'mp4', 'wav'];
5
+ const getAvailableContainers = () => {
6
+ return availableContainers;
7
+ };
8
+ exports.getAvailableContainers = getAvailableContainers;
@@ -0,0 +1,7 @@
1
+ import type { ConvertMediaContainer } from './get-available-containers';
2
+ declare const availableVideoCodecs: readonly ["vp8", "vp9", "h264"];
3
+ export type ConvertMediaVideoCodec = (typeof availableVideoCodecs)[number];
4
+ export declare const getAvailableVideoCodecs: ({ container, }: {
5
+ container: ConvertMediaContainer;
6
+ }) => ConvertMediaVideoCodec[];
7
+ export {};
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getAvailableVideoCodecs = void 0;
4
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
5
+ const availableVideoCodecs = ['vp8', 'vp9', 'h264'];
6
+ const getAvailableVideoCodecs = ({ container, }) => {
7
+ if (container === 'mp4') {
8
+ return ['h264'];
9
+ }
10
+ if (container === 'webm') {
11
+ return ['vp8', 'vp9'];
12
+ }
13
+ if (container === 'wav') {
14
+ return [];
15
+ }
16
+ throw new Error(`Unsupported container: ${container}`);
17
+ };
18
+ exports.getAvailableVideoCodecs = getAvailableVideoCodecs;
@@ -1,4 +1,5 @@
1
- import type { ConvertMediaAudioCodec, ConvertMediaContainer } from './codec-id';
1
+ import type { ConvertMediaAudioCodec } from './get-available-audio-codecs';
2
+ import type { ConvertMediaContainer } from './get-available-containers';
2
3
  export declare const getDefaultAudioCodec: ({ container, }: {
3
4
  container: ConvertMediaContainer;
4
5
  }) => ConvertMediaAudioCodec;
@@ -8,6 +8,9 @@ const getDefaultAudioCodec = ({ container, }) => {
8
8
  if (container === 'mp4') {
9
9
  return 'aac';
10
10
  }
11
+ if (container === 'wav') {
12
+ return 'wav';
13
+ }
11
14
  throw new Error(`Unhandled container: ${container}`);
12
15
  };
13
16
  exports.getDefaultAudioCodec = getDefaultAudioCodec;
@@ -1,4 +1,5 @@
1
- import type { ConvertMediaContainer, ConvertMediaVideoCodec } from './codec-id';
1
+ import type { ConvertMediaContainer } from './get-available-containers';
2
+ import type { ConvertMediaVideoCodec } from './get-available-video-codecs';
2
3
  export declare const getDefaultVideoCodec: ({ container, }: {
3
4
  container: ConvertMediaContainer;
4
- }) => ConvertMediaVideoCodec;
5
+ }) => ConvertMediaVideoCodec | null;
@@ -5,6 +5,12 @@ const getDefaultVideoCodec = ({ container, }) => {
5
5
  if (container === 'webm') {
6
6
  return 'vp8';
7
7
  }
8
- throw new Error(`Unhandled container: ${container} satisfies never`);
8
+ if (container === 'mp4') {
9
+ return 'h264';
10
+ }
11
+ if (container === 'wav') {
12
+ return null;
13
+ }
14
+ throw new Error(`Unhandled container: ${container}`);
9
15
  };
10
16
  exports.getDefaultVideoCodec = getDefaultVideoCodec;
package/dist/index.d.ts CHANGED
@@ -4,10 +4,12 @@ export { canCopyAudioTrack } from './can-copy-audio-track';
4
4
  export { canCopyVideoTrack } from './can-copy-video-track';
5
5
  export { canReencodeAudioTrack } from './can-reencode-audio-track';
6
6
  export { canReencodeVideoTrack } from './can-reencode-video-track';
7
- export { ConvertMediaAudioCodec, ConvertMediaContainer, ConvertMediaVideoCodec, getAvailableAudioCodecs, getAvailableContainers, getAvailableVideoCodecs, } from './codec-id';
8
7
  export { convertMedia, ConvertMediaOnProgress, ConvertMediaOnVideoFrame, ConvertMediaProgress, ConvertMediaResult, } from './convert-media';
9
8
  export { defaultOnAudioTrackHandler } from './default-on-audio-track-handler';
10
9
  export { defaultOnVideoTrackHandler } from './default-on-video-track-handler';
10
+ export { ConvertMediaAudioCodec, getAvailableAudioCodecs, } from './get-available-audio-codecs';
11
+ export { ConvertMediaContainer, getAvailableContainers, } from './get-available-containers';
12
+ export { ConvertMediaVideoCodec, getAvailableVideoCodecs, } from './get-available-video-codecs';
11
13
  export { getDefaultAudioCodec } from './get-default-audio-codec';
12
14
  export { getDefaultVideoCodec } from './get-default-video-codec';
13
15
  export { AudioOperation, ConvertMediaOnAudioTrackHandler, } from './on-audio-track-handler';
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createVideoEncoder = exports.createVideoDecoder = exports.getDefaultVideoCodec = exports.getDefaultAudioCodec = exports.defaultOnVideoTrackHandler = exports.defaultOnAudioTrackHandler = exports.convertMedia = exports.getAvailableVideoCodecs = exports.getAvailableContainers = exports.getAvailableAudioCodecs = exports.canReencodeVideoTrack = exports.canReencodeAudioTrack = exports.canCopyVideoTrack = exports.canCopyAudioTrack = exports.createAudioEncoder = exports.createAudioDecoder = void 0;
3
+ exports.createVideoEncoder = exports.createVideoDecoder = exports.getDefaultVideoCodec = exports.getDefaultAudioCodec = exports.getAvailableVideoCodecs = exports.getAvailableContainers = exports.getAvailableAudioCodecs = exports.defaultOnVideoTrackHandler = exports.defaultOnAudioTrackHandler = exports.convertMedia = exports.canReencodeVideoTrack = exports.canReencodeAudioTrack = exports.canCopyVideoTrack = exports.canCopyAudioTrack = exports.createAudioEncoder = exports.createAudioDecoder = void 0;
4
4
  const set_remotion_imported_1 = require("./set-remotion-imported");
5
5
  var audio_decoder_1 = require("./audio-decoder");
6
6
  Object.defineProperty(exports, "createAudioDecoder", { enumerable: true, get: function () { return audio_decoder_1.createAudioDecoder; } });
@@ -14,16 +14,18 @@ var can_reencode_audio_track_1 = require("./can-reencode-audio-track");
14
14
  Object.defineProperty(exports, "canReencodeAudioTrack", { enumerable: true, get: function () { return can_reencode_audio_track_1.canReencodeAudioTrack; } });
15
15
  var can_reencode_video_track_1 = require("./can-reencode-video-track");
16
16
  Object.defineProperty(exports, "canReencodeVideoTrack", { enumerable: true, get: function () { return can_reencode_video_track_1.canReencodeVideoTrack; } });
17
- var codec_id_1 = require("./codec-id");
18
- Object.defineProperty(exports, "getAvailableAudioCodecs", { enumerable: true, get: function () { return codec_id_1.getAvailableAudioCodecs; } });
19
- Object.defineProperty(exports, "getAvailableContainers", { enumerable: true, get: function () { return codec_id_1.getAvailableContainers; } });
20
- Object.defineProperty(exports, "getAvailableVideoCodecs", { enumerable: true, get: function () { return codec_id_1.getAvailableVideoCodecs; } });
21
17
  var convert_media_1 = require("./convert-media");
22
18
  Object.defineProperty(exports, "convertMedia", { enumerable: true, get: function () { return convert_media_1.convertMedia; } });
23
19
  var default_on_audio_track_handler_1 = require("./default-on-audio-track-handler");
24
20
  Object.defineProperty(exports, "defaultOnAudioTrackHandler", { enumerable: true, get: function () { return default_on_audio_track_handler_1.defaultOnAudioTrackHandler; } });
25
21
  var default_on_video_track_handler_1 = require("./default-on-video-track-handler");
26
22
  Object.defineProperty(exports, "defaultOnVideoTrackHandler", { enumerable: true, get: function () { return default_on_video_track_handler_1.defaultOnVideoTrackHandler; } });
23
+ var get_available_audio_codecs_1 = require("./get-available-audio-codecs");
24
+ Object.defineProperty(exports, "getAvailableAudioCodecs", { enumerable: true, get: function () { return get_available_audio_codecs_1.getAvailableAudioCodecs; } });
25
+ var get_available_containers_1 = require("./get-available-containers");
26
+ Object.defineProperty(exports, "getAvailableContainers", { enumerable: true, get: function () { return get_available_containers_1.getAvailableContainers; } });
27
+ var get_available_video_codecs_1 = require("./get-available-video-codecs");
28
+ Object.defineProperty(exports, "getAvailableVideoCodecs", { enumerable: true, get: function () { return get_available_video_codecs_1.getAvailableVideoCodecs; } });
27
29
  var get_default_audio_codec_1 = require("./get-default-audio-codec");
28
30
  Object.defineProperty(exports, "getDefaultAudioCodec", { enumerable: true, get: function () { return get_default_audio_codec_1.getDefaultAudioCodec; } });
29
31
  var get_default_video_codec_1 = require("./get-default-video-codec");
@@ -69,12 +69,18 @@ const makeIoSynchronizer = (logLevel, label) => {
69
69
  return promise;
70
70
  };
71
71
  const waitFor = async ({ _unprocessed, unemitted, }) => {
72
- while (getUnemittedItems() > unemitted) {
73
- await waitForOutput();
74
- }
75
- while (getUnprocessed() > _unprocessed) {
76
- await waitForProcessed();
77
- }
72
+ await Promise.all([
73
+ async () => {
74
+ while (getUnemittedItems() > unemitted) {
75
+ await waitForOutput();
76
+ }
77
+ },
78
+ async () => {
79
+ while (getUnprocessed() > _unprocessed) {
80
+ await waitForProcessed();
81
+ }
82
+ },
83
+ ]);
78
84
  };
79
85
  const waitForFinish = async () => {
80
86
  await waitFor({ _unprocessed: 0, unemitted: 0 });
@@ -1,5 +1,6 @@
1
1
  import type { AudioTrack, LogLevel } from '@remotion/media-parser';
2
- import type { ConvertMediaAudioCodec, ConvertMediaContainer } from './codec-id';
2
+ import type { ConvertMediaAudioCodec } from './get-available-audio-codecs';
3
+ import type { ConvertMediaContainer } from './get-available-containers';
3
4
  export type AudioOperation = {
4
5
  type: 'reencode';
5
6
  bitrate: number;
@@ -1,6 +1,7 @@
1
1
  import type { LogLevel, MediaFn, OnAudioTrack } from '@remotion/media-parser';
2
- import type { ConvertMediaAudioCodec, ConvertMediaContainer } from './codec-id';
3
2
  import Error from './error-cause';
3
+ import type { ConvertMediaAudioCodec } from './get-available-audio-codecs';
4
+ import type { ConvertMediaContainer } from './get-available-containers';
4
5
  import type { ConvertMediaOnAudioTrackHandler } from './on-audio-track-handler';
5
6
  import type { ConvertMediaProgressFn } from './throttled-state-update';
6
7
  export declare const makeAudioTrackHandler: ({ state, defaultAudioCodec: audioCodec, controller, abortConversion, onMediaStateUpdate, onAudioTrack, logLevel, container, }: {
@@ -74,7 +74,9 @@ const makeAudioTrackHandler = ({ state, defaultAudioCodec: audioCodec, controlle
74
74
  const codecPrivate = audioOperation.audioCodec === 'aac' ? new Uint8Array([17, 144]) : null;
75
75
  const { trackNumber } = await state.addTrack({
76
76
  type: 'audio',
77
- codec: audioOperation.audioCodec,
77
+ codec: audioOperation.audioCodec === 'wav'
78
+ ? 'pcm-s16'
79
+ : audioOperation.audioCodec,
78
80
  numberOfChannels: track.numberOfChannels,
79
81
  sampleRate: track.sampleRate,
80
82
  codecPrivate,
@@ -1,6 +1,6 @@
1
1
  import type { VideoTrack } from '@remotion/media-parser';
2
- import type { ConvertMediaVideoCodec } from './codec-id';
3
2
  import type { ConvertMediaOnVideoFrame } from './convert-media';
3
+ import type { ConvertMediaVideoCodec } from './get-available-video-codecs';
4
4
  import type { WebCodecsVideoEncoder } from './video-encoder';
5
5
  export declare const onFrame: ({ frame, onVideoFrame, videoEncoder, track, outputCodec, }: {
6
6
  frame: VideoFrame;
package/dist/on-frame.js CHANGED
@@ -4,12 +4,6 @@ exports.onFrame = void 0;
4
4
  const convert_to_correct_videoframe_1 = require("./convert-to-correct-videoframe");
5
5
  const onFrame = async ({ frame, onVideoFrame, videoEncoder, track, outputCodec, }) => {
6
6
  const newFrame = onVideoFrame ? await onVideoFrame({ frame, track }) : frame;
7
- if (newFrame.codedHeight !== frame.displayHeight) {
8
- throw new Error(`Returned VideoFrame of track ${track.trackId} has different codedHeight (${newFrame.codedHeight}) than the input frame displayHeight (${frame.displayHeight})`);
9
- }
10
- if (newFrame.codedWidth !== frame.displayWidth) {
11
- throw new Error(`Returned VideoFrame of track ${track.trackId} has different codedWidth (${newFrame.codedWidth}) than the input frame displayWidth (${frame.displayWidth})`);
12
- }
13
7
  if (newFrame.displayWidth !== frame.displayWidth) {
14
8
  throw new Error(`Returned VideoFrame of track ${track.trackId} has different displayWidth (${newFrame.displayWidth}) than the input frame (${newFrame.displayHeight})`);
15
9
  }
@@ -1,5 +1,6 @@
1
1
  import type { LogLevel, VideoTrack } from '@remotion/media-parser';
2
- import type { ConvertMediaContainer, ConvertMediaVideoCodec } from './codec-id';
2
+ import type { ConvertMediaContainer } from './get-available-containers';
3
+ import type { ConvertMediaVideoCodec } from './get-available-video-codecs';
3
4
  export type VideoOperation = {
4
5
  type: 'reencode';
5
6
  videoCodec: ConvertMediaVideoCodec;
@@ -1,7 +1,8 @@
1
1
  import type { LogLevel, MediaFn, OnVideoTrack } from '@remotion/media-parser';
2
- import type { ConvertMediaContainer, ConvertMediaVideoCodec } from './codec-id';
3
2
  import type { ConvertMediaOnVideoFrame } from './convert-media';
4
3
  import Error from './error-cause';
4
+ import type { ConvertMediaContainer } from './get-available-containers';
5
+ import type { ConvertMediaVideoCodec } from './get-available-video-codecs';
5
6
  import type { ConvertMediaOnVideoTrackHandler } from './on-video-track-handler';
6
7
  import type { ConvertMediaProgressFn } from './throttled-state-update';
7
8
  export declare const makeVideoTrackHandler: ({ state, onVideoFrame, onMediaStateUpdate, abortConversion, controller, defaultVideoCodec, onVideoTrack, logLevel, container, }: {
@@ -0,0 +1,2 @@
1
+ import type { ConvertMediaContainer } from './get-available-containers';
2
+ export declare const selectContainerCreator: (container: ConvertMediaContainer) => ({ writer, onBytesProgress, onMillisecondsProgress, logLevel, filename, }: import("@remotion/media-parser/dist/create/media-fn").MediaFnGeneratorInput) => Promise<import("@remotion/media-parser").MediaFn>;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.selectContainerCreator = void 0;
4
+ const media_parser_1 = require("@remotion/media-parser");
5
+ const selectContainerCreator = (container) => {
6
+ if (container === 'mp4') {
7
+ return media_parser_1.MediaParserInternals.createIsoBaseMedia;
8
+ }
9
+ if (container === 'wav') {
10
+ return media_parser_1.MediaParserInternals.createWav;
11
+ }
12
+ if (container === 'webm') {
13
+ return media_parser_1.MediaParserInternals.createMatroskaMedia;
14
+ }
15
+ throw new Error(`Unsupported container: ${container}`);
16
+ };
17
+ exports.selectContainerCreator = selectContainerCreator;
@@ -1,4 +1,4 @@
1
- import type { ConvertMediaVideoCodec } from './codec-id';
1
+ import type { ConvertMediaVideoCodec } from './get-available-video-codecs';
2
2
  export declare const getVideoEncoderConfig: ({ codec, height, width, fps, }: {
3
3
  width: number;
4
4
  height: number;
@@ -1,5 +1,5 @@
1
1
  import type { LogLevel } from '@remotion/media-parser';
2
- import type { ConvertMediaVideoCodec } from './codec-id';
2
+ import type { ConvertMediaVideoCodec } from './get-available-video-codecs';
3
3
  export type WebCodecsVideoEncoder = {
4
4
  encodeFrame: (videoFrame: VideoFrame, timestamp: number) => Promise<void>;
5
5
  waitForFinish: () => Promise<void>;
@@ -0,0 +1,2 @@
1
+ import type { AudioEncoderInit, WebCodecsAudioEncoder } from './audio-encoder';
2
+ export declare const getWaveAudioEncoder: ({ onChunk, signal, }: Pick<AudioEncoderInit, "onChunk" | "signal">) => WebCodecsAudioEncoder;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getWaveAudioEncoder = void 0;
4
+ const getWaveAudioEncoder = ({ onChunk, signal, }) => {
5
+ return {
6
+ close: () => {
7
+ return Promise.resolve();
8
+ },
9
+ encodeFrame: (audioData) => {
10
+ if (signal.aborted) {
11
+ return Promise.resolve();
12
+ }
13
+ const chunk = {
14
+ timestamp: audioData.timestamp,
15
+ duration: audioData.duration,
16
+ type: 'key',
17
+ copyTo: (destination) => audioData.copyTo(destination, { planeIndex: 0, format: 's16' }),
18
+ byteLength: audioData.allocationSize({ planeIndex: 0, format: 's16' }),
19
+ };
20
+ return onChunk(chunk);
21
+ },
22
+ flush: () => Promise.resolve(),
23
+ waitForFinish: () => Promise.resolve(),
24
+ };
25
+ };
26
+ exports.getWaveAudioEncoder = getWaveAudioEncoder;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remotion/webcodecs",
3
- "version": "4.0.231",
3
+ "version": "4.0.232",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "module": "dist/esm/index.mjs",
@@ -17,13 +17,13 @@
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.231"
20
+ "@remotion/media-parser": "4.0.232"
21
21
  },
22
22
  "peerDependencies": {},
23
23
  "devDependencies": {
24
24
  "@types/dom-webcodecs": "0.1.11",
25
25
  "eslint": "9.14.0",
26
- "@remotion/eslint-config-internal": "4.0.231"
26
+ "@remotion/eslint-config-internal": "4.0.232"
27
27
  },
28
28
  "keywords": [],
29
29
  "publishConfig": {