Skip to content

🎥 Make videos programmatically with React

add test

Jonny Burgerd14653c244c2
diff --git a/packages/convert/app/tests/test-list.tsx b/packages/convert/app/tests/test-list.tsx
index 780ea02e4a..35bc256251 100644
--- a/packages/convert/app/tests/test-list.tsx
+++ b/packages/convert/app/tests/test-list.tsx
@@ -1,12 +1,11 @@
import {convertMedia} from '@remotion/webcodecs';
import {flipVideoFrame} from '~/components/flip-video';
-import type {
- TestStructure} from './test-structure';
+import type {TestStructure} from './test-structure';
import {
addTestWatcher,
allowSafariAudioDrop,
isSafari,
- makeProgressReporter
+ makeProgressReporter,
} from './test-structure';
const basicMp4ToWebM = (): TestStructure => {
@@ -45,6 +44,25 @@ const av1WebmToMp4 = (): TestStructure => {
});
};
+const av1WebmToMp4H265 = (): TestStructure => {
+ const src =
+ 'https://remotion-assets.s3.eu-central-1.amazonaws.com/example-videos/av1-bbb.webm';
+
+ return addTestWatcher({
+ name: 'AV1 WebM to MP4 (H.265)',
+ src,
+ async execute(onUpdate) {
+ await convertMedia({
+ src,
+ container: 'mp4',
+ videoCodec: 'h265',
+ onAudioTrack: allowSafariAudioDrop,
+ onProgress: makeProgressReporter(onUpdate),
+ });
+ },
+ });
+};
+
const weirdMp4aConfig = (): TestStructure => {
const src =
'https://remotion-assets.s3.eu-central-1.amazonaws.com/example-videos/riverside.mp4';
@@ -268,6 +286,7 @@ export const testList: TestStructure[] = [
av1WebmToMp4(),
aviToMp4(),
aviToMp4ReEncode(),
+ av1WebmToMp4H265(),
convertToWav(),
weirdMp4aConfig(),
rotatedVideo(),
diff --git a/packages/webcodecs/src/convert-media.ts b/packages/webcodecs/src/convert-media.ts
index 947cc63aee..0450981226 100644
--- a/packages/webcodecs/src/convert-media.ts
+++ b/packages/webcodecs/src/convert-media.ts
@@ -22,8 +22,14 @@ import {withResolversAndWaitForReturn} from './create/with-resolvers';
import Error from './error-cause';
import {generateOutputFilename} from './generate-output-filename';
import type {ConvertMediaAudioCodec} from './get-available-audio-codecs';
-import type {ConvertMediaContainer} from './get-available-containers';
-import type {ConvertMediaVideoCodec} from './get-available-video-codecs';
+import {
+ availableContainers,
+ type ConvertMediaContainer,
+} from './get-available-containers';
+import {
+ availableVideoCodecs,
+ type ConvertMediaVideoCodec,
+} from './get-available-video-codecs';
import {Log} from './log';
import {makeAudioTrackHandler} from './on-audio-track';
import {type ConvertMediaOnAudioTrackHandler} from './on-audio-track-handler';
@@ -108,18 +114,18 @@ export const convertMedia = async function <
return Promise.reject(new Error('Aborted'));
}
- if (container !== 'webm' && container !== 'mp4' && container !== 'wav') {
+ if (container !== 'webm' && availableContainers.indexOf(container) === -1) {
return Promise.reject(
new TypeError(
- 'Only `to: "webm"`, `to: "mp4"` and `to: "wav"` is supported currently',
+ `Only the following values for "container" are supported currently: ${JSON.stringify(availableContainers)}`,
),
);
}
- if (videoCodec && videoCodec !== 'vp8' && videoCodec !== 'vp9') {
+ if (videoCodec && availableVideoCodecs.indexOf(videoCodec) === -1) {
return Promise.reject(
new TypeError(
- 'Only `videoCodec: "vp8"` and `videoCodec: "vp9"` are supported currently',
+ `Only the following values for "videoCodec" are supported currently: ${JSON.stringify(availableVideoCodecs)}`,
),
);
}
diff --git a/packages/webcodecs/src/get-available-containers.ts b/packages/webcodecs/src/get-available-containers.ts
index 88a795d6ec..acfca789ea 100644
--- a/packages/webcodecs/src/get-available-containers.ts
+++ b/packages/webcodecs/src/get-available-containers.ts
@@ -1,4 +1,4 @@
-const availableContainers = ['webm', 'mp4', 'wav'] as const;
+export const availableContainers = ['webm', 'mp4', 'wav'] as const;
export type ConvertMediaContainer = (typeof availableContainers)[number];
export const getAvailableContainers = (): readonly ConvertMediaContainer[] => {
diff --git a/packages/webcodecs/src/get-available-video-codecs.ts b/packages/webcodecs/src/get-available-video-codecs.ts
index 0f44b2e65a..7e79910962 100644
--- a/packages/webcodecs/src/get-available-video-codecs.ts
+++ b/packages/webcodecs/src/get-available-video-codecs.ts
@@ -1,7 +1,6 @@
import type {ConvertMediaContainer} from './get-available-containers';
-// eslint-disable-next-line @typescript-eslint/no-unused-vars
-const availableVideoCodecs = ['vp8', 'vp9', 'h264', 'h265'] as const;
+export const availableVideoCodecs = ['vp8', 'vp9', 'h264', 'h265'] as const;
export type ConvertMediaVideoCodec = (typeof availableVideoCodecs)[number];
export const getAvailableVideoCodecs = ({
diff --git a/packages/webcodecs/src/video-encoder-config.ts b/packages/webcodecs/src/video-encoder-config.ts
index 53891552e7..1206bf9f50 100644
--- a/packages/webcodecs/src/video-encoder-config.ts
+++ b/packages/webcodecs/src/video-encoder-config.ts
@@ -24,7 +24,6 @@ export const getVideoEncoderConfig = async ({
bitrate: isSafari() ? 3_000_000 : undefined,
bitrateMode: codec === 'vp9' && !isSafari() ? 'quantizer' : undefined,
};
- console.log(config);
const hardware: VideoEncoderConfig = {
...config,