webcodecs-node 0.5.0 → 0.5.2
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.
- package/README.md +64 -184
- package/docs/api.md +1 -1
- package/docs/configuration.md +6 -17
- package/package.json +2 -2
- package/dist/AudioData.d.ts +0 -6
- package/dist/AudioData.d.ts.map +0 -1
- package/dist/AudioData.js +0 -6
- package/dist/AudioData.js.map +0 -1
- package/dist/AudioDecoder.d.ts +0 -6
- package/dist/AudioDecoder.d.ts.map +0 -1
- package/dist/AudioDecoder.js +0 -6
- package/dist/AudioDecoder.js.map +0 -1
- package/dist/AudioEncoder.d.ts +0 -6
- package/dist/AudioEncoder.d.ts.map +0 -1
- package/dist/AudioEncoder.js +0 -6
- package/dist/AudioEncoder.js.map +0 -1
- package/dist/EncodedAudioChunk.d.ts +0 -6
- package/dist/EncodedAudioChunk.d.ts.map +0 -1
- package/dist/EncodedAudioChunk.js +0 -6
- package/dist/EncodedAudioChunk.js.map +0 -1
- package/dist/EncodedVideoChunk.d.ts +0 -6
- package/dist/EncodedVideoChunk.d.ts.map +0 -1
- package/dist/EncodedVideoChunk.js +0 -6
- package/dist/EncodedVideoChunk.js.map +0 -1
- package/dist/FFmpegProcess.d.ts +0 -6
- package/dist/FFmpegProcess.d.ts.map +0 -1
- package/dist/FFmpegProcess.js +0 -6
- package/dist/FFmpegProcess.js.map +0 -1
- package/dist/HardwareAcceleration.d.ts +0 -6
- package/dist/HardwareAcceleration.d.ts.map +0 -1
- package/dist/HardwareAcceleration.js +0 -6
- package/dist/HardwareAcceleration.js.map +0 -1
- package/dist/ImageDecoder.d.ts +0 -6
- package/dist/ImageDecoder.d.ts.map +0 -1
- package/dist/ImageDecoder.js +0 -6
- package/dist/ImageDecoder.js.map +0 -1
- package/dist/Logger.d.ts +0 -6
- package/dist/Logger.d.ts.map +0 -1
- package/dist/Logger.js +0 -6
- package/dist/Logger.js.map +0 -1
- package/dist/MediaCapabilities.d.ts +0 -9
- package/dist/MediaCapabilities.d.ts.map +0 -1
- package/dist/MediaCapabilities.js +0 -8
- package/dist/MediaCapabilities.js.map +0 -1
- package/dist/VideoDecoder.d.ts +0 -6
- package/dist/VideoDecoder.d.ts.map +0 -1
- package/dist/VideoDecoder.js +0 -6
- package/dist/VideoDecoder.js.map +0 -1
- package/dist/VideoEncoder.d.ts +0 -6
- package/dist/VideoEncoder.d.ts.map +0 -1
- package/dist/VideoEncoder.js +0 -6
- package/dist/VideoEncoder.js.map +0 -1
- package/dist/VideoFrame.d.ts +0 -10
- package/dist/VideoFrame.d.ts.map +0 -1
- package/dist/VideoFrame.js +0 -9
- package/dist/VideoFrame.js.map +0 -1
- package/dist/__tests__/AudioData.test.d.ts +0 -5
- package/dist/__tests__/AudioData.test.d.ts.map +0 -1
- package/dist/__tests__/AudioData.test.js +0 -180
- package/dist/__tests__/AudioData.test.js.map +0 -1
- package/dist/__tests__/AudioDecoder.test.d.ts +0 -5
- package/dist/__tests__/AudioDecoder.test.d.ts.map +0 -1
- package/dist/__tests__/AudioDecoder.test.js +0 -733
- package/dist/__tests__/AudioDecoder.test.js.map +0 -1
- package/dist/__tests__/AudioEncoder.test.d.ts +0 -5
- package/dist/__tests__/AudioEncoder.test.d.ts.map +0 -1
- package/dist/__tests__/AudioEncoder.test.js +0 -247
- package/dist/__tests__/AudioEncoder.test.js.map +0 -1
- package/dist/__tests__/EncodedChunks.test.d.ts +0 -5
- package/dist/__tests__/EncodedChunks.test.d.ts.map +0 -1
- package/dist/__tests__/EncodedChunks.test.js +0 -100
- package/dist/__tests__/EncodedChunks.test.js.map +0 -1
- package/dist/__tests__/HardwareAcceleration.test.d.ts +0 -5
- package/dist/__tests__/HardwareAcceleration.test.d.ts.map +0 -1
- package/dist/__tests__/HardwareAcceleration.test.js +0 -85
- package/dist/__tests__/HardwareAcceleration.test.js.map +0 -1
- package/dist/__tests__/ImageDecoder.test.d.ts +0 -5
- package/dist/__tests__/ImageDecoder.test.d.ts.map +0 -1
- package/dist/__tests__/ImageDecoder.test.js +0 -558
- package/dist/__tests__/ImageDecoder.test.js.map +0 -1
- package/dist/__tests__/ImageDecoder.wpt.test.d.ts +0 -8
- package/dist/__tests__/ImageDecoder.wpt.test.d.ts.map +0 -1
- package/dist/__tests__/ImageDecoder.wpt.test.js +0 -135
- package/dist/__tests__/ImageDecoder.wpt.test.js.map +0 -1
- package/dist/__tests__/MediaCapabilities.test.d.ts +0 -5
- package/dist/__tests__/MediaCapabilities.test.d.ts.map +0 -1
- package/dist/__tests__/MediaCapabilities.test.js +0 -346
- package/dist/__tests__/MediaCapabilities.test.js.map +0 -1
- package/dist/__tests__/NodeAvDecoder.test.d.ts +0 -2
- package/dist/__tests__/NodeAvDecoder.test.d.ts.map +0 -1
- package/dist/__tests__/NodeAvDecoder.test.js +0 -206
- package/dist/__tests__/NodeAvDecoder.test.js.map +0 -1
- package/dist/__tests__/NodeAvEncoder.test.d.ts +0 -2
- package/dist/__tests__/NodeAvEncoder.test.d.ts.map +0 -1
- package/dist/__tests__/NodeAvEncoder.test.js +0 -176
- package/dist/__tests__/NodeAvEncoder.test.js.map +0 -1
- package/dist/__tests__/VideoDecoder.test.d.ts +0 -5
- package/dist/__tests__/VideoDecoder.test.d.ts.map +0 -1
- package/dist/__tests__/VideoDecoder.test.js +0 -675
- package/dist/__tests__/VideoDecoder.test.js.map +0 -1
- package/dist/__tests__/VideoEncoder.test.d.ts +0 -5
- package/dist/__tests__/VideoEncoder.test.d.ts.map +0 -1
- package/dist/__tests__/VideoEncoder.test.js +0 -468
- package/dist/__tests__/VideoEncoder.test.js.map +0 -1
- package/dist/__tests__/VideoFrame.test.d.ts +0 -5
- package/dist/__tests__/VideoFrame.test.d.ts.map +0 -1
- package/dist/__tests__/VideoFrame.test.js +0 -246
- package/dist/__tests__/VideoFrame.test.js.map +0 -1
- package/dist/__tests__/aac-utils.test.d.ts +0 -2
- package/dist/__tests__/aac-utils.test.d.ts.map +0 -1
- package/dist/__tests__/aac-utils.test.js +0 -37
- package/dist/__tests__/aac-utils.test.js.map +0 -1
- package/dist/__tests__/avc-utils.test.d.ts +0 -2
- package/dist/__tests__/avc-utils.test.d.ts.map +0 -1
- package/dist/__tests__/avc-utils.test.js +0 -63
- package/dist/__tests__/avc-utils.test.js.map +0 -1
- package/dist/__tests__/hevc-utils.test.d.ts +0 -2
- package/dist/__tests__/hevc-utils.test.d.ts.map +0 -1
- package/dist/__tests__/hevc-utils.test.js +0 -78
- package/dist/__tests__/hevc-utils.test.js.map +0 -1
- package/dist/demos/demo-conversion.d.ts +0 -13
- package/dist/demos/demo-conversion.d.ts.map +0 -1
- package/dist/demos/demo-conversion.js +0 -301
- package/dist/demos/demo-conversion.js.map +0 -1
- package/dist/demos/demo-hwaccel-conversion.d.ts +0 -8
- package/dist/demos/demo-hwaccel-conversion.d.ts.map +0 -1
- package/dist/demos/demo-hwaccel-conversion.js +0 -161
- package/dist/demos/demo-hwaccel-conversion.js.map +0 -1
- package/dist/demos/demo-mediabunny.d.ts +0 -7
- package/dist/demos/demo-mediabunny.d.ts.map +0 -1
- package/dist/demos/demo-mediabunny.js +0 -78
- package/dist/demos/demo-mediabunny.js.map +0 -1
- package/dist/ffmpeg/FFmpegProcess.d.ts +0 -111
- package/dist/ffmpeg/FFmpegProcess.d.ts.map +0 -1
- package/dist/ffmpeg/FFmpegProcess.js +0 -543
- package/dist/ffmpeg/FFmpegProcess.js.map +0 -1
- package/dist/ffmpeg/audio-codecs.d.ts +0 -59
- package/dist/ffmpeg/audio-codecs.d.ts.map +0 -1
- package/dist/ffmpeg/audio-codecs.js +0 -99
- package/dist/ffmpeg/audio-codecs.js.map +0 -1
- package/dist/ffmpeg/formats.d.ts +0 -42
- package/dist/ffmpeg/formats.d.ts.map +0 -1
- package/dist/ffmpeg/formats.js +0 -147
- package/dist/ffmpeg/formats.js.map +0 -1
- package/dist/ffmpeg/index.d.ts +0 -10
- package/dist/ffmpeg/index.d.ts.map +0 -1
- package/dist/ffmpeg/index.js +0 -13
- package/dist/ffmpeg/index.js.map +0 -1
- package/dist/ffmpeg/parsers/annexb.d.ts +0 -88
- package/dist/ffmpeg/parsers/annexb.d.ts.map +0 -1
- package/dist/ffmpeg/parsers/annexb.js +0 -201
- package/dist/ffmpeg/parsers/annexb.js.map +0 -1
- package/dist/ffmpeg/parsers/index.d.ts +0 -6
- package/dist/ffmpeg/parsers/index.d.ts.map +0 -1
- package/dist/ffmpeg/parsers/index.js +0 -8
- package/dist/ffmpeg/parsers/index.js.map +0 -1
- package/dist/ffmpeg/parsers/ivf.d.ts +0 -54
- package/dist/ffmpeg/parsers/ivf.d.ts.map +0 -1
- package/dist/ffmpeg/parsers/ivf.js +0 -109
- package/dist/ffmpeg/parsers/ivf.js.map +0 -1
- package/dist/ffmpeg/types.d.ts +0 -85
- package/dist/ffmpeg/types.d.ts.map +0 -1
- package/dist/ffmpeg/types.js +0 -8
- package/dist/ffmpeg/types.js.map +0 -1
- package/dist/mediabunny/FFmpegAudioDecoder.d.ts +0 -24
- package/dist/mediabunny/FFmpegAudioDecoder.d.ts.map +0 -1
- package/dist/mediabunny/FFmpegAudioDecoder.js +0 -126
- package/dist/mediabunny/FFmpegAudioDecoder.js.map +0 -1
- package/dist/mediabunny/FFmpegAudioEncoder.d.ts +0 -44
- package/dist/mediabunny/FFmpegAudioEncoder.d.ts.map +0 -1
- package/dist/mediabunny/FFmpegAudioEncoder.js +0 -221
- package/dist/mediabunny/FFmpegAudioEncoder.js.map +0 -1
- package/dist/mediabunny/FFmpegVideoDecoder.d.ts +0 -25
- package/dist/mediabunny/FFmpegVideoDecoder.d.ts.map +0 -1
- package/dist/mediabunny/FFmpegVideoDecoder.js +0 -122
- package/dist/mediabunny/FFmpegVideoDecoder.js.map +0 -1
- package/dist/mediabunny/FFmpegVideoEncoder.d.ts +0 -49
- package/dist/mediabunny/FFmpegVideoEncoder.d.ts.map +0 -1
- package/dist/mediabunny/FFmpegVideoEncoder.js +0 -264
- package/dist/mediabunny/FFmpegVideoEncoder.js.map +0 -1
- package/dist/mediabunny/index.d.ts +0 -21
- package/dist/mediabunny/index.d.ts.map +0 -1
- package/dist/mediabunny/index.js +0 -33
- package/dist/mediabunny/index.js.map +0 -1
- package/dist/types.d.ts +0 -6
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -6
- package/dist/types.js.map +0 -1
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
import { VideoEncoder } from '../encoders/VideoEncoder.js';
|
|
2
|
-
import { VideoDecoder } from '../decoders/VideoDecoder.js';
|
|
3
|
-
import { VideoFrame } from '../core/VideoFrame.js';
|
|
4
|
-
/**
|
|
5
|
-
* Helper function to create test frames
|
|
6
|
-
*/
|
|
7
|
-
function createTestFrame(width, height, frameIndex) {
|
|
8
|
-
const data = new Uint8Array(width * height * 4);
|
|
9
|
-
for (let i = 0; i < data.length; i += 4) {
|
|
10
|
-
data[i] = 50 + frameIndex * 10; // R
|
|
11
|
-
data[i + 1] = 100; // G
|
|
12
|
-
data[i + 2] = 150; // B
|
|
13
|
-
data[i + 3] = 255; // A
|
|
14
|
-
}
|
|
15
|
-
return new VideoFrame(data, {
|
|
16
|
-
format: 'RGBA',
|
|
17
|
-
codedWidth: width,
|
|
18
|
-
codedHeight: height,
|
|
19
|
-
timestamp: frameIndex * 33333,
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Helper to encode frames and return chunks for decoding tests
|
|
24
|
-
*/
|
|
25
|
-
async function encodeFrames(codec, width, height, numFrames) {
|
|
26
|
-
const chunks = [];
|
|
27
|
-
let description;
|
|
28
|
-
let err = null;
|
|
29
|
-
const encoder = new VideoEncoder({
|
|
30
|
-
output: (chunk, metadata) => {
|
|
31
|
-
chunks.push(chunk);
|
|
32
|
-
if (metadata?.decoderConfig?.description) {
|
|
33
|
-
description = metadata.decoderConfig.description;
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
error: (e) => { err = e; },
|
|
37
|
-
});
|
|
38
|
-
encoder.configure({
|
|
39
|
-
codec,
|
|
40
|
-
width,
|
|
41
|
-
height,
|
|
42
|
-
framerate: 30,
|
|
43
|
-
bitrate: 500_000,
|
|
44
|
-
});
|
|
45
|
-
for (let f = 0; f < numFrames; f++) {
|
|
46
|
-
const frame = createTestFrame(width, height, f);
|
|
47
|
-
encoder.encode(frame, { keyFrame: f === 0 });
|
|
48
|
-
frame.close();
|
|
49
|
-
}
|
|
50
|
-
await encoder.flush();
|
|
51
|
-
encoder.close();
|
|
52
|
-
return { chunks, description, error: err };
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Helper to decode chunks and return frames
|
|
56
|
-
*/
|
|
57
|
-
async function decodeChunks(codec, chunks, width, height, outputFormat = 'I420', description) {
|
|
58
|
-
const frames = [];
|
|
59
|
-
let err = null;
|
|
60
|
-
const decoder = new VideoDecoder({
|
|
61
|
-
output: (frame) => frames.push(frame),
|
|
62
|
-
error: (e) => { err = e; },
|
|
63
|
-
});
|
|
64
|
-
decoder.configure({
|
|
65
|
-
codec,
|
|
66
|
-
codedWidth: width,
|
|
67
|
-
codedHeight: height,
|
|
68
|
-
outputFormat,
|
|
69
|
-
description,
|
|
70
|
-
});
|
|
71
|
-
for (const chunk of chunks) {
|
|
72
|
-
decoder.decode(chunk);
|
|
73
|
-
}
|
|
74
|
-
await decoder.flush();
|
|
75
|
-
decoder.close();
|
|
76
|
-
return { frames, error: err };
|
|
77
|
-
}
|
|
78
|
-
describe('NodeAV VideoDecoder backend', () => {
|
|
79
|
-
const width = 64;
|
|
80
|
-
const height = 64;
|
|
81
|
-
const numFrames = 3;
|
|
82
|
-
describe('H.264 (AVC) decoding', () => {
|
|
83
|
-
it('decodes h264 chunks produced by node-av encoder', async () => {
|
|
84
|
-
const codec = 'avc1.42001E';
|
|
85
|
-
const { chunks, error: encodeError } = await encodeFrames(codec, width, height, numFrames);
|
|
86
|
-
if (encodeError)
|
|
87
|
-
throw encodeError;
|
|
88
|
-
expect(chunks.length).toBeGreaterThan(0);
|
|
89
|
-
const { frames, error: decodeError } = await decodeChunks(codec, chunks, width, height);
|
|
90
|
-
if (decodeError)
|
|
91
|
-
throw decodeError;
|
|
92
|
-
expect(frames.length).toBeGreaterThan(0);
|
|
93
|
-
frames.forEach((f) => f.close());
|
|
94
|
-
}, 20000);
|
|
95
|
-
it('outputs RGBA format when requested', async () => {
|
|
96
|
-
const codec = 'avc1.42001E';
|
|
97
|
-
const { chunks, error: encodeError } = await encodeFrames(codec, width, height, numFrames);
|
|
98
|
-
if (encodeError)
|
|
99
|
-
throw encodeError;
|
|
100
|
-
const { frames, error: decodeError } = await decodeChunks(codec, chunks, width, height, 'RGBA');
|
|
101
|
-
if (decodeError)
|
|
102
|
-
throw decodeError;
|
|
103
|
-
expect(frames.length).toBeGreaterThan(0);
|
|
104
|
-
expect(frames[0].format).toBe('RGBA');
|
|
105
|
-
frames.forEach((f) => f.close());
|
|
106
|
-
}, 20000);
|
|
107
|
-
});
|
|
108
|
-
describe('H.265 (HEVC) decoding', () => {
|
|
109
|
-
it('decodes hevc chunks produced by node-av encoder', async () => {
|
|
110
|
-
const codec = 'hev1.1.6.L93.B0';
|
|
111
|
-
const { chunks, description, error: encodeError } = await encodeFrames(codec, width, height, numFrames);
|
|
112
|
-
if (encodeError)
|
|
113
|
-
throw encodeError;
|
|
114
|
-
expect(chunks.length).toBeGreaterThan(0);
|
|
115
|
-
const { frames, error: decodeError } = await decodeChunks(codec, chunks, width, height, 'I420', description);
|
|
116
|
-
if (decodeError)
|
|
117
|
-
throw decodeError;
|
|
118
|
-
expect(frames.length).toBeGreaterThan(0);
|
|
119
|
-
frames.forEach((f) => f.close());
|
|
120
|
-
}, 30000);
|
|
121
|
-
});
|
|
122
|
-
describe('VP8 decoding', () => {
|
|
123
|
-
it('decodes vp8 chunks produced by node-av encoder', async () => {
|
|
124
|
-
const codec = 'vp8';
|
|
125
|
-
const { chunks, error: encodeError } = await encodeFrames(codec, width, height, numFrames);
|
|
126
|
-
if (encodeError)
|
|
127
|
-
throw encodeError;
|
|
128
|
-
expect(chunks.length).toBeGreaterThan(0);
|
|
129
|
-
const { frames, error: decodeError } = await decodeChunks(codec, chunks, width, height);
|
|
130
|
-
if (decodeError)
|
|
131
|
-
throw decodeError;
|
|
132
|
-
expect(frames.length).toBeGreaterThan(0);
|
|
133
|
-
frames.forEach((f) => f.close());
|
|
134
|
-
}, 20000);
|
|
135
|
-
});
|
|
136
|
-
describe('VP9 decoding', () => {
|
|
137
|
-
it('decodes vp9 chunks produced by node-av encoder', async () => {
|
|
138
|
-
const codec = 'vp09.00.10.08';
|
|
139
|
-
const { chunks, error: encodeError } = await encodeFrames(codec, width, height, numFrames);
|
|
140
|
-
if (encodeError)
|
|
141
|
-
throw encodeError;
|
|
142
|
-
expect(chunks.length).toBeGreaterThan(0);
|
|
143
|
-
const { frames, error: decodeError } = await decodeChunks(codec, chunks, width, height);
|
|
144
|
-
if (decodeError)
|
|
145
|
-
throw decodeError;
|
|
146
|
-
expect(frames.length).toBeGreaterThan(0);
|
|
147
|
-
frames.forEach((f) => f.close());
|
|
148
|
-
}, 30000);
|
|
149
|
-
it('decodes with vp9 codec string', async () => {
|
|
150
|
-
const codec = 'vp9';
|
|
151
|
-
const { chunks, error: encodeError } = await encodeFrames(codec, width, height, numFrames);
|
|
152
|
-
if (encodeError)
|
|
153
|
-
throw encodeError;
|
|
154
|
-
expect(chunks.length).toBeGreaterThan(0);
|
|
155
|
-
const { frames, error: decodeError } = await decodeChunks(codec, chunks, width, height);
|
|
156
|
-
if (decodeError)
|
|
157
|
-
throw decodeError;
|
|
158
|
-
expect(frames.length).toBeGreaterThan(0);
|
|
159
|
-
frames.forEach((f) => f.close());
|
|
160
|
-
}, 30000);
|
|
161
|
-
});
|
|
162
|
-
describe('AV1 decoding', () => {
|
|
163
|
-
it('decodes av1 chunks produced by node-av encoder', async () => {
|
|
164
|
-
const codec = 'av01.0.01M.08';
|
|
165
|
-
const { chunks, error: encodeError } = await encodeFrames(codec, width, height, numFrames);
|
|
166
|
-
if (encodeError)
|
|
167
|
-
throw encodeError;
|
|
168
|
-
expect(chunks.length).toBeGreaterThan(0);
|
|
169
|
-
const { frames, error: decodeError } = await decodeChunks(codec, chunks, width, height);
|
|
170
|
-
if (decodeError)
|
|
171
|
-
throw decodeError;
|
|
172
|
-
expect(frames.length).toBeGreaterThan(0);
|
|
173
|
-
frames.forEach((f) => f.close());
|
|
174
|
-
}, 60000); // AV1 can be slow
|
|
175
|
-
it('decodes with av1 codec string', async () => {
|
|
176
|
-
const codec = 'av1';
|
|
177
|
-
const { chunks, error: encodeError } = await encodeFrames(codec, width, height, numFrames);
|
|
178
|
-
if (encodeError)
|
|
179
|
-
throw encodeError;
|
|
180
|
-
expect(chunks.length).toBeGreaterThan(0);
|
|
181
|
-
const { frames, error: decodeError } = await decodeChunks(codec, chunks, width, height);
|
|
182
|
-
if (decodeError)
|
|
183
|
-
throw decodeError;
|
|
184
|
-
expect(frames.length).toBeGreaterThan(0);
|
|
185
|
-
frames.forEach((f) => f.close());
|
|
186
|
-
}, 60000);
|
|
187
|
-
});
|
|
188
|
-
describe('Round-trip encoding/decoding', () => {
|
|
189
|
-
it('preserves frame dimensions through encode/decode cycle', async () => {
|
|
190
|
-
const codec = 'avc1.42001E';
|
|
191
|
-
const { chunks, error: encodeError } = await encodeFrames(codec, width, height, numFrames);
|
|
192
|
-
if (encodeError)
|
|
193
|
-
throw encodeError;
|
|
194
|
-
const { frames, error: decodeError } = await decodeChunks(codec, chunks, width, height);
|
|
195
|
-
if (decodeError)
|
|
196
|
-
throw decodeError;
|
|
197
|
-
expect(frames.length).toBeGreaterThan(0);
|
|
198
|
-
for (const frame of frames) {
|
|
199
|
-
expect(frame.codedWidth).toBe(width);
|
|
200
|
-
expect(frame.codedHeight).toBe(height);
|
|
201
|
-
frame.close();
|
|
202
|
-
}
|
|
203
|
-
}, 20000);
|
|
204
|
-
});
|
|
205
|
-
});
|
|
206
|
-
//# sourceMappingURL=NodeAvDecoder.test.js.map
|
|
@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K,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;YACxF,IAAI,WAAW;gBAAE,MAAM,WAAW,CAAC;YAEnC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;YACzC,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;gBAC3B,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBACrC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;gBACvC,KAAK,CAAC,KAAK,EAAE,CAAC;YAChB,CAAC;QACH,CAAC,EAAE,KAAK,CAAC,CAAC;IACZ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NodeAvEncoder.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/NodeAvEncoder.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
import { VideoEncoder } from '../encoders/VideoEncoder.js';
|
|
2
|
-
import { VideoFrame } from '../core/VideoFrame.js';
|
|
3
|
-
/**
|
|
4
|
-
* Helper function to create test frames
|
|
5
|
-
*/
|
|
6
|
-
function createTestFrame(width, height, frameIndex) {
|
|
7
|
-
const data = new Uint8Array(width * height * 4);
|
|
8
|
-
for (let i = 0; i < data.length; i += 4) {
|
|
9
|
-
data[i] = 50 + frameIndex * 10; // R
|
|
10
|
-
data[i + 1] = 100; // G
|
|
11
|
-
data[i + 2] = 150; // B
|
|
12
|
-
data[i + 3] = 255; // A
|
|
13
|
-
}
|
|
14
|
-
return new VideoFrame(data, {
|
|
15
|
-
format: 'RGBA',
|
|
16
|
-
codedWidth: width,
|
|
17
|
-
codedHeight: height,
|
|
18
|
-
timestamp: frameIndex * 33333,
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Helper function to encode test frames and return chunks
|
|
23
|
-
*/
|
|
24
|
-
async function encodeTestFrames(codec, width, height, numFrames) {
|
|
25
|
-
const chunks = [];
|
|
26
|
-
let err = null;
|
|
27
|
-
const encoder = new VideoEncoder({
|
|
28
|
-
output: (chunk) => chunks.push(chunk),
|
|
29
|
-
error: (e) => { err = e; },
|
|
30
|
-
});
|
|
31
|
-
encoder.configure({
|
|
32
|
-
codec,
|
|
33
|
-
width,
|
|
34
|
-
height,
|
|
35
|
-
framerate: 30,
|
|
36
|
-
bitrate: 500_000,
|
|
37
|
-
});
|
|
38
|
-
for (let f = 0; f < numFrames; f++) {
|
|
39
|
-
const frame = createTestFrame(width, height, f);
|
|
40
|
-
encoder.encode(frame, { keyFrame: f === 0 });
|
|
41
|
-
frame.close();
|
|
42
|
-
}
|
|
43
|
-
await encoder.flush();
|
|
44
|
-
encoder.close();
|
|
45
|
-
return { chunks, error: err };
|
|
46
|
-
}
|
|
47
|
-
describe('NodeAV VideoEncoder backend', () => {
|
|
48
|
-
const width = 64;
|
|
49
|
-
const height = 64;
|
|
50
|
-
const numFrames = 3;
|
|
51
|
-
describe('H.264 (AVC) encoding', () => {
|
|
52
|
-
it('encodes RGBA input via node-av backend', async () => {
|
|
53
|
-
const { chunks, error } = await encodeTestFrames('avc1.42001E', width, height, numFrames);
|
|
54
|
-
if (error) {
|
|
55
|
-
throw error;
|
|
56
|
-
}
|
|
57
|
-
expect(chunks.length).toBeGreaterThan(0);
|
|
58
|
-
expect(chunks[0].type).toBe('key');
|
|
59
|
-
}, 20000);
|
|
60
|
-
it('encodes YUV420P input via node-av backend', async () => {
|
|
61
|
-
const chunks = [];
|
|
62
|
-
let err = null;
|
|
63
|
-
const encoder = new VideoEncoder({
|
|
64
|
-
output: (chunk) => chunks.push(chunk),
|
|
65
|
-
error: (e) => { err = e; },
|
|
66
|
-
});
|
|
67
|
-
encoder.configure({
|
|
68
|
-
codec: 'avc1.42001E',
|
|
69
|
-
width,
|
|
70
|
-
height,
|
|
71
|
-
framerate: 30,
|
|
72
|
-
bitrate: 500_000,
|
|
73
|
-
});
|
|
74
|
-
// Create I420 frames
|
|
75
|
-
const ySize = width * height;
|
|
76
|
-
const uvSize = (width / 2) * (height / 2);
|
|
77
|
-
const frameSize = ySize + 2 * uvSize;
|
|
78
|
-
for (let f = 0; f < numFrames; f++) {
|
|
79
|
-
const data = new Uint8Array(frameSize);
|
|
80
|
-
// Fill Y plane with varying luminance
|
|
81
|
-
for (let i = 0; i < ySize; i++) {
|
|
82
|
-
data[i] = 128 + f * 10;
|
|
83
|
-
}
|
|
84
|
-
// Fill U and V planes with neutral values
|
|
85
|
-
for (let i = ySize; i < frameSize; i++) {
|
|
86
|
-
data[i] = 128;
|
|
87
|
-
}
|
|
88
|
-
const frame = new VideoFrame(data, {
|
|
89
|
-
format: 'I420',
|
|
90
|
-
codedWidth: width,
|
|
91
|
-
codedHeight: height,
|
|
92
|
-
timestamp: f * 33333,
|
|
93
|
-
});
|
|
94
|
-
encoder.encode(frame, { keyFrame: f === 0 });
|
|
95
|
-
frame.close();
|
|
96
|
-
}
|
|
97
|
-
await encoder.flush();
|
|
98
|
-
encoder.close();
|
|
99
|
-
if (err) {
|
|
100
|
-
throw err;
|
|
101
|
-
}
|
|
102
|
-
expect(chunks.length).toBeGreaterThan(0);
|
|
103
|
-
}, 20000);
|
|
104
|
-
});
|
|
105
|
-
describe('H.265 (HEVC) encoding', () => {
|
|
106
|
-
it('encodes RGBA input via node-av backend', async () => {
|
|
107
|
-
const { chunks, error } = await encodeTestFrames('hev1.1.6.L93.B0', width, height, numFrames);
|
|
108
|
-
if (error) {
|
|
109
|
-
throw error;
|
|
110
|
-
}
|
|
111
|
-
expect(chunks.length).toBeGreaterThan(0);
|
|
112
|
-
expect(chunks[0].type).toBe('key');
|
|
113
|
-
}, 30000);
|
|
114
|
-
});
|
|
115
|
-
describe('VP8 encoding', () => {
|
|
116
|
-
it('encodes RGBA input via node-av backend', async () => {
|
|
117
|
-
const { chunks, error } = await encodeTestFrames('vp8', width, height, numFrames);
|
|
118
|
-
if (error) {
|
|
119
|
-
throw error;
|
|
120
|
-
}
|
|
121
|
-
expect(chunks.length).toBeGreaterThan(0);
|
|
122
|
-
expect(chunks[0].type).toBe('key');
|
|
123
|
-
}, 20000);
|
|
124
|
-
});
|
|
125
|
-
describe('VP9 encoding', () => {
|
|
126
|
-
it('encodes RGBA input via node-av backend', async () => {
|
|
127
|
-
const { chunks, error } = await encodeTestFrames('vp09.00.10.08', width, height, numFrames);
|
|
128
|
-
if (error) {
|
|
129
|
-
throw error;
|
|
130
|
-
}
|
|
131
|
-
expect(chunks.length).toBeGreaterThan(0);
|
|
132
|
-
expect(chunks[0].type).toBe('key');
|
|
133
|
-
}, 30000);
|
|
134
|
-
it('encodes with vp9 codec string', async () => {
|
|
135
|
-
const { chunks, error } = await encodeTestFrames('vp9', width, height, numFrames);
|
|
136
|
-
if (error) {
|
|
137
|
-
throw error;
|
|
138
|
-
}
|
|
139
|
-
expect(chunks.length).toBeGreaterThan(0);
|
|
140
|
-
}, 30000);
|
|
141
|
-
});
|
|
142
|
-
describe('AV1 encoding', () => {
|
|
143
|
-
it('encodes RGBA input via node-av backend', async () => {
|
|
144
|
-
const { chunks, error } = await encodeTestFrames('av01.0.01M.08', width, height, numFrames);
|
|
145
|
-
if (error) {
|
|
146
|
-
throw error;
|
|
147
|
-
}
|
|
148
|
-
expect(chunks.length).toBeGreaterThan(0);
|
|
149
|
-
expect(chunks[0].type).toBe('key');
|
|
150
|
-
}, 60000); // AV1 encoding can be slow
|
|
151
|
-
it('encodes with av1 codec string', async () => {
|
|
152
|
-
const { chunks, error } = await encodeTestFrames('av1', width, height, numFrames);
|
|
153
|
-
if (error) {
|
|
154
|
-
throw error;
|
|
155
|
-
}
|
|
156
|
-
expect(chunks.length).toBeGreaterThan(0);
|
|
157
|
-
}, 60000);
|
|
158
|
-
});
|
|
159
|
-
describe('Error handling', () => {
|
|
160
|
-
it('handles invalid codec gracefully', async () => {
|
|
161
|
-
const encoder = new VideoEncoder({
|
|
162
|
-
output: () => { },
|
|
163
|
-
error: () => { },
|
|
164
|
-
});
|
|
165
|
-
expect(() => {
|
|
166
|
-
encoder.configure({
|
|
167
|
-
codec: 'invalid-codec',
|
|
168
|
-
width: 64,
|
|
169
|
-
height: 64,
|
|
170
|
-
});
|
|
171
|
-
}).toThrow();
|
|
172
|
-
encoder.close();
|
|
173
|
-
});
|
|
174
|
-
});
|
|
175
|
-
});
|
|
176
|
-
//# sourceMappingURL=NodeAvEncoder.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NodeAvEncoder.test.js","sourceRoot":"","sources":["../../src/__tests__/NodeAvEncoder.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAGnD;;GAEG;AACH,SAAS,eAAe,CAAC,KAAa,EAAE,MAAc,EAAE,UAAkB;IACxE,MAAM,IAAI,GAAG,IAAI,UAAU,CAAC,KAAK,GAAG,MAAM,GAAG,CAAC,CAAC,CAAC;IAChD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QACxC,IAAI,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,UAAU,GAAG,EAAE,CAAC,CAAK,IAAI;QACxC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,CAAmB,IAAI;QACzC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,CAAmB,IAAI;QACzC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,CAAmB,IAAI;IAC3C,CAAC;IAED,OAAO,IAAI,UAAU,CAAC,IAAI,EAAE;QAC1B,MAAM,EAAE,MAAM;QACd,UA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