AvFrameVideoSampleResource
A custom VideoSampleResource backed by NodeAV's Frame, which in turn is backed by FFmpeg's AVFrame. You can use this resource to create VideoSample instances that are directly backed by FFmpeg's AVFrame without data having to be copied. Since AVFrames can themselves be backed by data on the GPU, this enables zero-copy hardware-accelerated decode and encode paths.
When using Electron, you can directly create Frame instances without the data having to leave the GPU. For more, see NodeAV's docs.
When passed, the Frame is now owned by resource, meaning it takes care of closing the frame later. If you want to keep a copy for your own use, clone the frame first.
Extends: VideoSampleResource
Constructor
constructor(
frame: NodeAv.Frame,
): AvFrameVideoSampleResource;Properties
frame
get frame(): Frame;The NodeAV Frame instance backing this resource. Access throws if the resource has already been closed.
Methods
close()
close(): void;getCodedHeight()
getCodedHeight(): number;Returns the height of the frame in pixels.
getCodedWidth()
getCodedWidth(): number;Returns the width of the frame in pixels.
getColorSpace()
getColorSpace(): VideoSampleColorSpace;Returns the color space of the frame.
getDataPlanes()
getDataPlanes(): MaybePromise<VideoDataPlane[]>;Returns the data planes that hold the video data for this sample. The returned planes and data must be in the format returned by getFormat().
See MaybePromise and VideoDataPlane.
getFormat()
getFormat(): "I420" | "I420P10" | "I420P12" | "I420A" | "I420AP10" | "I420AP12" | "I422" | "I422P10" | "I422P12" | "I422A" | "I422AP10" | "I422AP12" | "I444" | "I444P10" | "I444P12" | "I444A" | ... 7 more ... | null;Returns the internal pixel format in which the frame is stored. See pixel formats
getSquarePixelHeight()
getSquarePixelHeight(): number;Returns the height of the frame in square pixels, respecting pixel aspect ratio.
getSquarePixelWidth()
getSquarePixelWidth(): number;Returns the width of the frame in square pixels, respecting pixel aspect ratio.
toRgbSample()
toRgbSample(
init: SetRequired<VideoSampleInit, 'timestamp'>,
colorSpace: PredefinedColorSpace,
): Promise<VideoSample>;See SetRequired, VideoSampleInit, and VideoSample.