@mediabunny/server 1.45.3 → 1.45.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -52,11 +52,11 @@ class NodeAvVideoEncoder extends mediabunny_1.CustomVideoEncoder {
52
52
  constructor() {
53
53
  super(...arguments);
54
54
  this.codecContext = null;
55
+ this.scaler = null;
56
+ this.dstFrame = null;
55
57
  this.lastBuffer = null;
56
58
  this.packetEmitted = false;
57
- this.scaler = null;
58
59
  this.lastScalerKey = null;
59
- this.dstFrame = null;
60
60
  // Bookkeeping to restore the original timing information
61
61
  this.preciseTimings = [];
62
62
  }
@@ -164,9 +164,13 @@ class NodeAvVideoEncoder extends mediabunny_1.CustomVideoEncoder {
164
164
  async encode(videoSample, options) {
165
165
  if (this.codecContext === null) {
166
166
  await this.createCodecContext();
167
- (0, misc_2.assert)(this.codecContext);
168
167
  }
168
+ (0, misc_2.assert)(this.codecContext);
169
169
  if (videoSample._data instanceof video_sample_1.AvFrameVideoSampleResource) {
170
+ // Release any buffers still referenced from the previous encode before reffing the new frame, otherwise
171
+ // av_frame_ref leaks them
172
+ // https://github.com/Vanilagy/mediabunny/issues/392
173
+ this.frame.unref();
170
174
  this.frame.ref(videoSample._data.frame);
171
175
  }
172
176
  else {