mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-09-29 03:43:50 +02:00
Change VideoSampleResource interface, validate return values, add more proper VideoSample.copyTo() logic, fix decoder/encoder color space issues
This commit is contained in:
@@ -35,7 +35,6 @@ export class NodeAvVideoEncoder extends CustomVideoEncoder {
|
||||
avCodec!: NodeAv.Codec;
|
||||
codecContext: NodeAv.CodecContext | null = null;
|
||||
lastBuffer: Buffer | null = null;
|
||||
colorSpaceSet = false;
|
||||
packetEmitted = false;
|
||||
|
||||
scaler: NodeAv.SoftwareScaleContext | null = null;
|
||||
@@ -65,6 +64,7 @@ export class NodeAvVideoEncoder extends CustomVideoEncoder {
|
||||
this.packet.alloc();
|
||||
|
||||
const codecId = CODEC_TO_CODEC_ID[this.codec];
|
||||
assert(codecId !== undefined);
|
||||
|
||||
let codec: NodeAv.Codec | null = null;
|
||||
if (this.config.hardwareAcceleration === 'prefer-software') {
|
||||
@@ -203,15 +203,6 @@ export class NodeAvVideoEncoder extends CustomVideoEncoder {
|
||||
this.frame.fromBuffer(this.lastBuffer);
|
||||
}
|
||||
|
||||
if (!this.colorSpaceSet) {
|
||||
this.codecContext.colorPrimaries = this.frame.colorPrimaries;
|
||||
this.codecContext.colorTrc = this.frame.colorTrc;
|
||||
this.codecContext.colorSpace = this.frame.colorSpace;
|
||||
this.codecContext.colorRange = this.frame.colorRange;
|
||||
|
||||
this.colorSpaceSet = true;
|
||||
}
|
||||
|
||||
let frameToEncode = this.frame;
|
||||
|
||||
const requiresScaler
|
||||
@@ -550,7 +541,6 @@ export class NodeAvVideoEncoder extends CustomVideoEncoder {
|
||||
}
|
||||
|
||||
this.packetEmitted = false;
|
||||
this.colorSpaceSet = false;
|
||||
}
|
||||
|
||||
close(): MaybePromise<void> {
|
||||
|
||||
Reference in New Issue
Block a user