Skip to content

🎥 Make videos programmatically with React

Update extract-audio.test.ts

Jonny Burgerd8f9b3ec0dcd
diff --git a/packages/renderer/src/test/extract-audio.test.ts b/packages/renderer/src/test/extract-audio.test.ts
index b5e47f310f..3e620a1287 100644
--- a/packages/renderer/src/test/extract-audio.test.ts
+++ b/packages/renderer/src/test/extract-audio.test.ts
@@ -1,22 +1,46 @@
-import {test} from 'vitest';
+import {unlinkSync} from 'node:fs';
+import {expect, test} from 'vitest';
import {extractAudio} from '../extract-audio';
import {exampleVideos} from './example-videos';
test('Should be able to extract the audio from a mp4 format video', async () => {
+ const audioOutput = exampleVideos.bigBuckBunny.replace(
+ 'bigbuckbunny.mp4',
+ 'bigbuckbunny.aac',
+ );
await extractAudio({
videoSource: exampleVideos.bigBuckBunny,
- audioOutput: exampleVideos.bigBuckBunny.replace(
- 'bigbuckbunny.mp4',
- 'bigbuckbunny.aac',
- ),
- logLevel: 'verbose',
+ audioOutput,
+ logLevel: 'info',
});
+ unlinkSync(audioOutput);
});
-test('Should be able to extract the audio from a webm format video', async () => {
+test('Should not be able to extract the audio with the wrong audio format', async () => {
+ const audioOutput = exampleVideos.bigBuckBunny.replace(
+ 'bigbuckbunny.mp4',
+ 'bigbuckbunny.opus',
+ );
+ await expect(() => {
+ return extractAudio({
+ videoSource: exampleVideos.webcam,
+ audioOutput,
+ logLevel: 'info',
+ });
+ }).rejects.toMatch(
+ /Input audio codec: 'AV_CODEC_ID_OPUS'. Error: Invalid argument/,
+ );
+});
+
+test('Should be able to extract the audio from a webm with the right format', async () => {
+ const audioOutput = exampleVideos.webcam.replace(
+ 'webcam.webm',
+ 'webcam.opus',
+ );
await extractAudio({
videoSource: exampleVideos.webcam,
- audioOutput: exampleVideos.webcam.replace('webcam.webm', 'webcam.aac'),
- logLevel: 'verbose',
+ audioOutput,
+ logLevel: 'info',
});
+ unlinkSync(audioOutput);
});