diff --git a/package.json b/package.json index b191d84..7bf6f55 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@lumen5/framefusion", - "version": "1.0.5", + "version": "1.0.6", "type": "module", "scripts": { "docs": "typedoc framefusion.ts", diff --git a/src/backends/beamcoder.ts b/src/backends/beamcoder.ts index 7ce5757..71681a1 100644 --- a/src/backends/beamcoder.ts +++ b/src/backends/beamcoder.ts @@ -41,6 +41,13 @@ const createDecoder = ({ }); } + if (demuxer.streams[streamIndex].codecpar.name === 'vp9') { + return beamcoder.decoder({ + ...commonParams, + name: 'libvpx-vp9', + }); + } + return beamcoder.decoder({ ...commonParams, demuxer: demuxer, diff --git a/test/__image_snapshots__/framefusion-test-ts-test-framefusion-test-ts-frame-fusion-can-get-frame-from-webm-with-alpha-1-snap.png b/test/__image_snapshots__/framefusion-test-ts-test-framefusion-test-ts-frame-fusion-can-get-frame-from-vp-8-encoded-webm-with-alpha-1-snap.png similarity index 100% rename from test/__image_snapshots__/framefusion-test-ts-test-framefusion-test-ts-frame-fusion-can-get-frame-from-webm-with-alpha-1-snap.png rename to test/__image_snapshots__/framefusion-test-ts-test-framefusion-test-ts-frame-fusion-can-get-frame-from-vp-8-encoded-webm-with-alpha-1-snap.png diff --git a/test/__image_snapshots__/framefusion-test-ts-test-framefusion-test-ts-frame-fusion-can-get-frame-from-vp-9-encoded-webm-with-alpha-1-snap.png b/test/__image_snapshots__/framefusion-test-ts-test-framefusion-test-ts-frame-fusion-can-get-frame-from-vp-9-encoded-webm-with-alpha-1-snap.png new file mode 100644 index 0000000..ee6e9c2 Binary files /dev/null and b/test/__image_snapshots__/framefusion-test-ts-test-framefusion-test-ts-frame-fusion-can-get-frame-from-vp-9-encoded-webm-with-alpha-1-snap.png differ diff --git a/test/framefusion.test.ts b/test/framefusion.test.ts index b1b4762..2420d5b 100644 --- a/test/framefusion.test.ts +++ b/test/framefusion.test.ts @@ -145,10 +145,31 @@ describe('FrameFusion', () => { await extractor.dispose(); }); - it('can get frame from webm with alpha', async() => { + it('can get frame from vp8 encoded webm with alpha', async() => { // Arrange const extractor = await BeamcoderExtractor.create({ - inputFileOrUrl: './test/samples/webm-with-alpha.webm', + inputFileOrUrl: './test/samples/vp8-webm-with-alpha.webm', + threadCount: 8, + }); + + // Act and Assert + const imageData = await extractor.getImageDataAtTime(100); + const canvasImageData = createImageData(imageData.data, imageData.width, imageData.height); + + const canvas = createCanvas(imageData.width, imageData.height); + const ctx = canvas.getContext('2d', { alpha: true }); + + ctx.putImageData(canvasImageData, 0, 0); + expect(canvas.toBuffer('image/png')).toMatchImageSnapshot(); + + // Cleanup + await extractor.dispose(); + }); + + it('can get frame from vp9 encoded webm with alpha', async() => { + // Arrange + const extractor = await BeamcoderExtractor.create({ + inputFileOrUrl: './test/samples/vp9-webm-with-alpha.webm', threadCount: 8, }); diff --git a/test/samples/webm-with-alpha.webm b/test/samples/vp8-webm-with-alpha.webm similarity index 100% rename from test/samples/webm-with-alpha.webm rename to test/samples/vp8-webm-with-alpha.webm diff --git a/test/samples/vp9-webm-with-alpha.webm b/test/samples/vp9-webm-with-alpha.webm new file mode 100644 index 0000000..a6dd633 Binary files /dev/null and b/test/samples/vp9-webm-with-alpha.webm differ