mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-09-27 10:53:50 +02:00
Fix workspace structure, fix AAC channel layout, fix incorrect import, enable HW-accelerated video decode by default
This commit is contained in:
@@ -94,8 +94,5 @@ jobs:
|
|||||||
packages/flac-encoder/dist/bundles/mediabunny-flac-encoder.min.mjs
|
packages/flac-encoder/dist/bundles/mediabunny-flac-encoder.min.mjs
|
||||||
packages/flac-encoder/dist/mediabunny-flac-encoder.d.ts
|
packages/flac-encoder/dist/mediabunny-flac-encoder.d.ts
|
||||||
|
|
||||||
- name: Publish Mediabunny to npm
|
|
||||||
run: npm publish --access public ${{ github.event.release.prerelease && '--tag beta' || '' }}
|
|
||||||
|
|
||||||
- name: Publish workspace packages to npm
|
- name: Publish workspace packages to npm
|
||||||
run: npm publish --access public --workspaces ${{ github.event.release.prerelease && '--tag beta' || '' }}
|
run: npm publish --access public --workspaces ${{ github.event.release.prerelease && '--tag beta' || '' }}
|
||||||
|
|||||||
Generated
+7
-20
@@ -9,6 +9,7 @@
|
|||||||
"version": "1.44.2",
|
"version": "1.44.2",
|
||||||
"license": "MPL-2.0",
|
"license": "MPL-2.0",
|
||||||
"workspaces": [
|
"workspaces": [
|
||||||
|
".",
|
||||||
"packages/*"
|
"packages/*"
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -8278,22 +8279,8 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/mediabunny": {
|
"node_modules/mediabunny": {
|
||||||
"version": "1.44.0",
|
"resolved": "",
|
||||||
"resolved": "https://registry.npmjs.org/mediabunny/-/mediabunny-1.44.0.tgz",
|
"link": true
|
||||||
"integrity": "sha512-rs54ixLAe5MSa6q35MVsVXyXZ+aYkEZYhAw57bseil+mmxFuqAS8YrELaWBcsqAJLCTb8Tse4AoYEhtkwCHYlQ==",
|
|
||||||
"license": "MPL-2.0",
|
|
||||||
"peer": true,
|
|
||||||
"workspaces": [
|
|
||||||
"packages/*"
|
|
||||||
],
|
|
||||||
"dependencies": {
|
|
||||||
"@types/dom-mediacapture-transform": "^0.1.11",
|
|
||||||
"@types/dom-webcodecs": "0.1.13"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"type": "individual",
|
|
||||||
"url": "https://github.com/sponsors/Vanilagy"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"node_modules/mensch": {
|
"node_modules/mensch": {
|
||||||
"version": "0.3.4",
|
"version": "0.3.4",
|
||||||
@@ -12851,7 +12838,7 @@
|
|||||||
},
|
},
|
||||||
"packages/aac-encoder": {
|
"packages/aac-encoder": {
|
||||||
"name": "@mediabunny/aac-encoder",
|
"name": "@mediabunny/aac-encoder",
|
||||||
"version": "1.44.1",
|
"version": "1.44.2",
|
||||||
"license": "MPL-2.0",
|
"license": "MPL-2.0",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/emscripten": "^1.40.1"
|
"@types/emscripten": "^1.40.1"
|
||||||
@@ -12866,7 +12853,7 @@
|
|||||||
},
|
},
|
||||||
"packages/ac3": {
|
"packages/ac3": {
|
||||||
"name": "@mediabunny/ac3",
|
"name": "@mediabunny/ac3",
|
||||||
"version": "1.44.1",
|
"version": "1.44.2",
|
||||||
"license": "MPL-2.0",
|
"license": "MPL-2.0",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/emscripten": "^1.40.1"
|
"@types/emscripten": "^1.40.1"
|
||||||
@@ -12881,7 +12868,7 @@
|
|||||||
},
|
},
|
||||||
"packages/flac-encoder": {
|
"packages/flac-encoder": {
|
||||||
"name": "@mediabunny/flac-encoder",
|
"name": "@mediabunny/flac-encoder",
|
||||||
"version": "1.44.1",
|
"version": "1.44.2",
|
||||||
"license": "MPL-2.0",
|
"license": "MPL-2.0",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/emscripten": "^1.40.1"
|
"@types/emscripten": "^1.40.1"
|
||||||
@@ -12896,7 +12883,7 @@
|
|||||||
},
|
},
|
||||||
"packages/mp3-encoder": {
|
"packages/mp3-encoder": {
|
||||||
"name": "@mediabunny/mp3-encoder",
|
"name": "@mediabunny/mp3-encoder",
|
||||||
"version": "1.44.1",
|
"version": "1.44.2",
|
||||||
"license": "MPL-2.0",
|
"license": "MPL-2.0",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/emscripten": "^1.40.1"
|
"@types/emscripten": "^1.40.1"
|
||||||
|
|||||||
+5
-4
@@ -5,6 +5,7 @@
|
|||||||
"description": "Pure TypeScript media toolkit for reading, writing, and converting media files, directly in the browser.",
|
"description": "Pure TypeScript media toolkit for reading, writing, and converting media files, directly in the browser.",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"workspaces": [
|
"workspaces": [
|
||||||
|
".",
|
||||||
"packages/*"
|
"packages/*"
|
||||||
],
|
],
|
||||||
"main": "./dist/bundles/mediabunny.cjs",
|
"main": "./dist/bundles/mediabunny.cjs",
|
||||||
@@ -55,10 +56,10 @@
|
|||||||
"examples:build": "vite build",
|
"examples:build": "vite build",
|
||||||
"fix-build-import-paths": "tsx scripts/add-import-extensions.ts",
|
"fix-build-import-paths": "tsx scripts/add-import-extensions.ts",
|
||||||
"append-namespace": "echo 'export as namespace Mediabunny;' >> dist/mediabunny.d.ts",
|
"append-namespace": "echo 'export as namespace Mediabunny;' >> dist/mediabunny.d.ts",
|
||||||
"bump-patch": "npm version patch --no-git-tag-version --workspaces --include-workspace-root",
|
"bump-patch": "npm version patch --no-git-tag-version --workspaces",
|
||||||
"bump-minor": "npm version minor --no-git-tag-version --workspaces --include-workspace-root",
|
"bump-minor": "npm version minor --no-git-tag-version --workspaces",
|
||||||
"bump-major": "npm version major --no-git-tag-version --workspaces --include-workspace-root",
|
"bump-major": "npm version major --no-git-tag-version --workspaces",
|
||||||
"set-version": "npm version --no-git-tag-version --workspaces --include-workspace-root"
|
"set-version": "npm version --no-git-tag-version --workspaces"
|
||||||
},
|
},
|
||||||
"license": "MPL-2.0",
|
"license": "MPL-2.0",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|||||||
@@ -3,7 +3,11 @@ import * as NodeAv from 'node-av';
|
|||||||
import { CODEC_TO_CODEC_ID, fromAudioSampleFormat, getChannelLayout } from './misc';
|
import { CODEC_TO_CODEC_ID, fromAudioSampleFormat, getChannelLayout } from './misc';
|
||||||
import { assert, toUint8Array } from '../../../src/misc';
|
import { assert, toUint8Array } from '../../../src/misc';
|
||||||
import { NodeAvFrameAudioSampleResource } from './audio-sample';
|
import { NodeAvFrameAudioSampleResource } from './audio-sample';
|
||||||
import { AdtsHeaderTemplate, buildAdtsHeaderTemplate, parseAacAudioSpecificConfig } from '../../../shared/aac-misc';
|
import {
|
||||||
|
AdtsHeaderTemplate,
|
||||||
|
buildAdtsHeaderTemplate,
|
||||||
|
parseAacAudioSpecificConfig,
|
||||||
|
} from '../../../shared/aac-misc';
|
||||||
|
|
||||||
const AAC_SAMPLE_RATES
|
const AAC_SAMPLE_RATES
|
||||||
= [96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, 8000, 7350];
|
= [96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, 8000, 7350];
|
||||||
@@ -261,18 +265,34 @@ export class NodeAvAudioEncoder extends CustomAudioEncoder {
|
|||||||
? toUint8Array(this.codecContext.extraData)
|
? toUint8Array(this.codecContext.extraData)
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
if (
|
if (this.codec === 'aac') {
|
||||||
description
|
if (!description) {
|
||||||
|
throw new Error('Extradata expected for AAC.');
|
||||||
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line @stylistic/max-len
|
// eslint-disable-next-line @stylistic/max-len
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access
|
||||||
&& this.codec === 'aac' && (this.config as any).aac?.format === 'adts'
|
const isAdts = (this.config as any).aac?.format === 'adts';
|
||||||
) {
|
|
||||||
const config = parseAacAudioSpecificConfig(description);
|
if (isAdts) {
|
||||||
this.adtsHeaderTemplate = buildAdtsHeaderTemplate(config);
|
const parsedConfig = parseAacAudioSpecificConfig(description);
|
||||||
description = undefined; // Not used with 'adts' format
|
this.adtsHeaderTemplate = buildAdtsHeaderTemplate(parsedConfig);
|
||||||
}
|
description = undefined; // Not used with 'adts' format
|
||||||
|
}
|
||||||
|
} else if (this.codec === 'opus') {
|
||||||
|
if (!description) {
|
||||||
|
// Technically not required by the WebCodecs/Mediabunny Codec Registry, but we strive to be better
|
||||||
|
throw new Error('Extradata expected for Opus.');
|
||||||
|
}
|
||||||
|
} else if (this.codec === 'vorbis') {
|
||||||
|
if (!description) {
|
||||||
|
throw new Error('Extradata expected for Vorbis.');
|
||||||
|
}
|
||||||
|
} else if (this.codec === 'flac') {
|
||||||
|
if (!description) {
|
||||||
|
throw new Error('Extradata expected for FLAC.');
|
||||||
|
}
|
||||||
|
|
||||||
if (description && this.codec === 'flac') {
|
|
||||||
// FFmpeg uses the STREAMINFO block as the extradata, but WebCodecs wants a different format:
|
// FFmpeg uses the STREAMINFO block as the extradata, but WebCodecs wants a different format:
|
||||||
// 1. The bytes 0x66 0x4C 0x61 0x43 ("fLaC" in ASCII)
|
// 1. The bytes 0x66 0x4C 0x61 0x43 ("fLaC" in ASCII)
|
||||||
// 2. A metadata block (called the STREAMINFO block) as described in section 7 of [FLAC]
|
// 2. A metadata block (called the STREAMINFO block) as described in section 7 of [FLAC]
|
||||||
|
|||||||
@@ -224,7 +224,7 @@ export const getChannelLayout = (numChannels: number): NodeAv.ChannelLayout => {
|
|||||||
case 1: return NodeAv.AV_CHANNEL_LAYOUT_MONO;
|
case 1: return NodeAv.AV_CHANNEL_LAYOUT_MONO;
|
||||||
case 2: return NodeAv.AV_CHANNEL_LAYOUT_STEREO;
|
case 2: return NodeAv.AV_CHANNEL_LAYOUT_STEREO;
|
||||||
case 4: return NodeAv.AV_CHANNEL_LAYOUT_QUAD;
|
case 4: return NodeAv.AV_CHANNEL_LAYOUT_QUAD;
|
||||||
case 6: return NodeAv.AV_CHANNEL_LAYOUT_5POINT1;
|
case 6: return NodeAv.AV_CHANNEL_LAYOUT_5POINT1_BACK;
|
||||||
case 8: return NodeAv.AV_CHANNEL_LAYOUT_7POINT1;
|
case 8: return NodeAv.AV_CHANNEL_LAYOUT_7POINT1;
|
||||||
default: return { nbChannels: numChannels, order: NodeAv.AV_CHANNEL_ORDER_UNSPEC, mask: 0n };
|
default: return { nbChannels: numChannels, order: NodeAv.AV_CHANNEL_ORDER_UNSPEC, mask: 0n };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,8 +40,14 @@ export class NodeAvVideoDecoder extends CustomVideoDecoder {
|
|||||||
let codec: NodeAv.Codec | null;
|
let codec: NodeAv.Codec | null;
|
||||||
if (this.codec === 'vp9' && packet.sideData.alpha) {
|
if (this.codec === 'vp9' && packet.sideData.alpha) {
|
||||||
codec = NodeAv.Codec.findDecoderByName(LIBVPX_VP9) ?? NodeAv.Codec.findDecoder(codecId);
|
codec = NodeAv.Codec.findDecoderByName(LIBVPX_VP9) ?? NodeAv.Codec.findDecoder(codecId);
|
||||||
} else if (this.config.hardwareAcceleration !== 'prefer-hardware' || this.codec === 'av1') {
|
} else if (
|
||||||
// https://github.com/opencv/opencv/issues/24430
|
// This check used to be "is not prefer-hardware", meaning it would default to using software decode. I
|
||||||
|
// didn't leave a comment for that back then so I actually don't know what it was for. I'm sure it was to
|
||||||
|
// work around an issue but, I don't know. Not using hardware decode at all by defaults feels wrong to me,
|
||||||
|
// so I changed it to what it is right now. If an issue is encountered, I can always change it.
|
||||||
|
this.config.hardwareAcceleration === 'prefer-software'
|
||||||
|
|| this.codec === 'av1' // https://github.com/opencv/opencv/issues/24430
|
||||||
|
) {
|
||||||
codec = NodeAv.Codec.findDecoder(codecId);
|
codec = NodeAv.Codec.findDecoder(codecId);
|
||||||
} else {
|
} else {
|
||||||
codec = getHardwareDecoderCodec(codecId) ?? NodeAv.Codec.findDecoder(codecId);
|
codec = getHardwareDecoderCodec(codecId) ?? NodeAv.Codec.findDecoder(codecId);
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import assert from 'assert';
|
|
||||||
import {
|
import {
|
||||||
VideoSamplePixelFormat,
|
VideoSamplePixelFormat,
|
||||||
VideoSampleResource,
|
VideoSampleResource,
|
||||||
@@ -10,7 +9,7 @@ import {
|
|||||||
VideoSampleTransformationDescription,
|
VideoSampleTransformationDescription,
|
||||||
} from 'mediabunny';
|
} from 'mediabunny';
|
||||||
import * as NodeAv from 'node-av';
|
import * as NodeAv from 'node-av';
|
||||||
import { MaybePromise, toUint8Array } from '../../../src/misc';
|
import { assert, MaybePromise, toUint8Array } from '../../../src/misc';
|
||||||
import {
|
import {
|
||||||
toPixelFormat,
|
toPixelFormat,
|
||||||
unmapColorPrimaries,
|
unmapColorPrimaries,
|
||||||
|
|||||||
Reference in New Issue
Block a user