@scrypted/libav 1.0.11 → 1.0.13

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scrypted/libav",
3
- "version": "1.0.11",
3
+ "version": "1.0.13",
4
4
  "dependencies": {
5
5
  "node-addon-api": "^8.1.0",
6
6
  "prebuild-install": "npm:@scrypted/prebuild-install@^7.1.8"
package/src/decode.cpp CHANGED
@@ -83,6 +83,7 @@ public:
83
83
  // Decode video frames
84
84
  while (av_read_frame(fmt_ctx_, packet) >= 0)
85
85
  {
86
+ fprintf(stdout, "read a frame\n");
86
87
  if (packet->stream_index != videoStreamIndex)
87
88
  {
88
89
  continue;
@@ -99,6 +100,7 @@ public:
99
100
  }
100
101
  av_packet_unref(packet); // Reset the packet for the next frame
101
102
  }
103
+ fprintf(stdout, "finished reading a frame\n");
102
104
 
103
105
  av_frame_free(&frame);
104
106
  av_packet_free(&packet);
@@ -141,7 +143,6 @@ public:
141
143
  private:
142
144
  static Napi::FunctionReference constructor;
143
145
  AVFormatContext *fmt_ctx_;
144
- bool owns_context_; // Flag to indicate if we should free the context
145
146
  int videoStreamIndex;
146
147
  AVCodecContext *codecContext;
147
148
  AVBufferRef *hw_device_ctx;
@@ -200,7 +201,6 @@ Napi::Object AVFormatContextObject::Init(Napi::Env env, Napi::Object exports)
200
201
 
201
202
  AVFormatContextObject::AVFormatContextObject(const Napi::CallbackInfo &info)
202
203
  : Napi::ObjectWrap<AVFormatContextObject>(info),
203
- owns_context_(true),
204
204
  videoStreamIndex(-1),
205
205
  codecContext(nullptr),
206
206
  hw_device_ctx(nullptr)
@@ -221,7 +221,6 @@ AVFormatContextObject::AVFormatContextObject(const Napi::CallbackInfo &info)
221
221
  }
222
222
 
223
223
  fmt_ctx_ = reinterpret_cast<AVFormatContext *>(value);
224
- owns_context_ = false; // We don't own this context, so we shouldn't free it
225
224
  }
226
225
  else
227
226
  {
@@ -232,7 +231,6 @@ AVFormatContextObject::AVFormatContextObject(const Napi::CallbackInfo &info)
232
231
  Napi::Error::New(env, "Failed to allocate AVFormatContext").ThrowAsJavaScriptException();
233
232
  return;
234
233
  }
235
- owns_context_ = true; // We own this context, so we should free it when done
236
234
  }
237
235
  }
238
236
 
@@ -514,18 +512,11 @@ Napi::Value AVFormatContextObject::Open(const Napi::CallbackInfo &info)
514
512
 
515
513
  AVFormatContextObject::~AVFormatContextObject()
516
514
  {
517
- if (owns_context_ && fmt_ctx_)
518
- {
519
- av_log(NULL, AV_LOG_INFO, "Destroyng AVFormatContext\n");
520
- avformat_close_input(&fmt_ctx_);
521
- avformat_free_context(fmt_ctx_);
522
- fmt_ctx_ = nullptr;
523
- }
524
515
  }
525
516
 
526
517
  Napi::Value AVFormatContextObject::Close(const Napi::CallbackInfo &info)
527
518
  {
528
- if (owns_context_ && fmt_ctx_)
519
+ if (fmt_ctx_)
529
520
  {
530
521
  av_log(NULL, AV_LOG_INFO, "Closing AVFormatContext\n");
531
522
  avformat_close_input(&fmt_ctx_);
package/src/filter.cpp CHANGED
@@ -63,11 +63,6 @@ AVFilterGraphObject::AVFilterGraphObject(const Napi::CallbackInfo &info)
63
63
 
64
64
  AVFilterGraphObject::~AVFilterGraphObject()
65
65
  {
66
- if (filterGraph)
67
- {
68
- avfilter_graph_free(&filterGraph);
69
- filterGraph = nullptr;
70
- }
71
66
  }
72
67
 
73
68
  Napi::Value AVFilterGraphObject::Destroy(const Napi::CallbackInfo &info)
package/src/frame.cpp CHANGED
@@ -82,11 +82,6 @@ AVFrameObject::AVFrameObject(const Napi::CallbackInfo &info)
82
82
 
83
83
  AVFrameObject::~AVFrameObject()
84
84
  {
85
- if (frame_)
86
- {
87
- av_frame_free(&frame_);
88
- frame_ = nullptr;
89
- }
90
85
  }
91
86
 
92
87
  Napi::Value AVFrameObject::ToJPEG(const Napi::CallbackInfo &info)