/*! * 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 { CustomVideoEncoder, type MaybePromise, VideoCodec, VideoSample } from 'mediabunny'; import * as NodeAv from 'node-av'; import { VideoBitDepth } from '../../../src/codec'; /** * The transfer characteristics to signal for output encoded at `outputBitDepth`, given what the incoming frames claim. * PQ and HLG are defined from 10 bits up, so encoding shallower leaves the label describing samples that no longer * exist; the transfer is then stated as unspecified rather than stamped onto bytes that cannot carry it. */ export declare const transferForOutputBitDepth: (frameColorTrc: NodeAv.AVColorTransferCharacteristic, outputBitDepth: VideoBitDepth | null) => NodeAv.AVColorTransferCharacteristic; /** * Picks the pixel format the codec context will be opened with. A bit depth demanded by the codec string is either * met or refused; where none is demanded, the incoming frames' depth is preserved when the encoder can. */ export declare const choosePixelFormat: (options: { codecName: string | null | undefined; /** * The chroma format the codec profile fixes, where it fixes one, so it is not left to the encoder's * own ordering. ProRes states it in the four-character code; most codecs state nothing and pass null. */ chromaFormat?: "420" | "422" | "444" | null; /** Null when the encoder advertises no list, in which case any depth is assumed reachable. */ supportedPixelFormats: NodeAv.AVPixelFormat[] | null; /** The depth the codec string states, which the output will be labelled with. */ requestedBitDepth: VideoBitDepth | null; /** The depth of the frames handed to the encoder. */ incomingBitDepth: VideoBitDepth | null; wantsAlpha: boolean; }) => NodeAv.AVPixelFormat; export declare class NodeAvVideoEncoder extends CustomVideoEncoder { frame: NodeAv.Frame; packet: NodeAv.Packet; codecContext: NodeAv.CodecContext | null; scaler: NodeAv.SoftwareScaleContext | null; dstFrame: NodeAv.Frame | null; avCodec: NodeAv.Codec; lastBuffer: Buffer | null; /** * The codec context's time base: microseconds, except for MPEG-2, which derives its `frame_rate_code` * from it and rejects a microsecond base as 1000000 fps. */ ptsTimeBase: { num: number; den: number; }; packetEmitted: boolean; quantizer: number | null; preciseTimings: { microsecondTimestamp: number; timestamp: number; duration: number; timestampIsValid: boolean; durationIsValid: boolean; }[]; static supports(codec: VideoCodec, config: VideoEncoderConfig): boolean; init(): Promise; /** * Opens the context, and where a hardware encoder will not open, opens a software one instead. * * `prefer-hardware` is a preference: a build can carry a device encoder for a device that is not * there — node-av's linux-arm64 prebuild carries `h264_rkmpp` on every arm64 machine — and whether * it is really there is only known from trying to open it. A codec asked for outright is not * second-guessed, so `prefer-software` never lands here. */ private createCodecContextWithSoftwareFallback; toTicks(microseconds: number): number; toMicroseconds(ticks: number): number; createCodecContext(): Promise; private applyEncoderControls; encode(videoSample: VideoSample, options: VideoEncoderEncodeOptions): Promise; receivePacket(ret: number): void; flush(): Promise; close(): MaybePromise; } //# sourceMappingURL=video-encoder.d.ts.map