mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-10-03 13:53:53 +02:00
Preserve rotation when calling .toVideoFrame()
This commit is contained in:
+16
-6
@@ -379,24 +379,34 @@ export class VideoSample implements Disposable {
|
|||||||
assert(this._data !== null);
|
assert(this._data !== null);
|
||||||
|
|
||||||
if (isVideoFrame(this._data)) {
|
if (isVideoFrame(this._data)) {
|
||||||
return new VideoFrame(this._data, {
|
const init: VideoFrameInit = {
|
||||||
timestamp: this.microsecondTimestamp,
|
timestamp: this.microsecondTimestamp,
|
||||||
duration: this.microsecondDuration || undefined, // Drag 0 duration to undefined, glitches some codecs
|
duration: this.microsecondDuration || undefined, // Drag 0 duration to undefined, glitches some codecs
|
||||||
});
|
// @ts-expect-error - WebCodecs types do not yet support rotation
|
||||||
|
rotation: this.rotation,
|
||||||
|
};
|
||||||
|
return new VideoFrame(this._data, init);
|
||||||
} else if (this._data instanceof Uint8Array) {
|
} else if (this._data instanceof Uint8Array) {
|
||||||
return new VideoFrame(this._data, {
|
const init: VideoFrameBufferInit = {
|
||||||
format: this.format!,
|
format: this.format!,
|
||||||
codedWidth: this.codedWidth,
|
codedWidth: this.codedWidth,
|
||||||
codedHeight: this.codedHeight,
|
codedHeight: this.codedHeight,
|
||||||
timestamp: this.microsecondTimestamp,
|
timestamp: this.microsecondTimestamp,
|
||||||
duration: this.microsecondDuration || undefined,
|
duration: this.microsecondDuration || undefined,
|
||||||
colorSpace: this.colorSpace,
|
colorSpace: this.colorSpace,
|
||||||
});
|
// @ts-expect-error - WebCodecs types do not yet support rotation
|
||||||
|
rotation: this.rotation,
|
||||||
|
};
|
||||||
|
|
||||||
|
return new VideoFrame(this._data, init);
|
||||||
} else {
|
} else {
|
||||||
return new VideoFrame(this._data, {
|
const init: VideoFrameInit = {
|
||||||
timestamp: this.microsecondTimestamp,
|
timestamp: this.microsecondTimestamp,
|
||||||
duration: this.microsecondDuration || undefined,
|
duration: this.microsecondDuration || undefined,
|
||||||
});
|
// @ts-expect-error - WebCodecs types do not yet support rotation
|
||||||
|
rotation: this.rotation,
|
||||||
|
};
|
||||||
|
return new VideoFrame(this._data, init);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user