Add license headers, add @mediabunny/server to build process, add doc blocks, small fixes

This commit is contained in:
Vanilagy
2026-05-12 15:04:32 +02:00
parent 633d1bc235
commit af43f67835
15 changed files with 197 additions and 27 deletions
+25
View File
@@ -1,3 +1,11 @@
/*!
* Copyright (c) 2026-present, Vanilagy and contributors
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
import { registerDecoder, registerEncoder, registerVideoSampleTransformer } from 'mediabunny';
import * as NodeAv from 'node-av';
import { NodeAvVideoDecoder } from './video-decoder';
@@ -18,6 +26,20 @@ if ((globalThis as Record<symbol, unknown>)[SERVER_LOADED_SYMBOL]) {
(globalThis as Record<symbol, unknown>)[SERVER_LOADED_SYMBOL] = true;
let registered = false;
/**
* Registers video and audio decoders and encoders for all codecs, using FFmpeg's libavcodec under the hood.
* Additionally, a custom `VideoSample` transformer based on libavfilter is registered to enable resizing, rotation and
* cropping of video frames.
*
* Make sure to call this function before interacting with Mediabunny.
*
* The decoders and encoders will automatically detect hardware acceleration support for each codec and platform and
* make use of it if applicable.
*
* @group \@mediabunny/server
* @public
*/
export const registerMediabunnyServer = () => {
if (registered) {
return;
@@ -36,3 +58,6 @@ export const registerMediabunnyServer = () => {
registerVideoSampleTransformer(transformVideoSample);
};
export { NodeAvFrameVideoSampleResource } from './video-sample';
export { NodeAvFrameAudioSampleResource } from './audio-sample';