-
-
Notifications
You must be signed in to change notification settings - Fork 55
/
Copy pathffmpeg.test.js
30 lines (27 loc) · 953 Bytes
/
ffmpeg.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/* eslint-disable */
const fs = require('node:fs');
const prism = require('../');
const { promisify } = require('util');
const readFile = promisify(fs.readFile);
const { roughlyEquals, streamToBuffer } = require('./util');
test('FFmpeg transcoder available', () => {
expect(prism.FFmpeg).toBeTruthy();
expect(prism.FFmpeg.getInfo().command).toBeTruthy();
expect(prism.FFmpeg.getInfo().output).toBeTruthy();
expect(prism.FFmpeg.getInfo().version).toBeTruthy();
});
test('FFmpeg transcoder to PCM is sane', async () => {
const output = fs.createReadStream('./test/audio/speech_orig.ogg')
.pipe(new prism.FFmpeg({
args: [
'-analyzeduration', '0',
'-loglevel', '0',
'-f', 's16le',
'-ar', '48000',
'-ac', '2',
],
}));
const chunks = await streamToBuffer(output);
const file = await readFile('./test/audio/speech_orig.pcm');
expect(roughlyEquals(file, chunks)).toEqual(true);
});