@scrypted/libav 1.0.20 → 1.0.22

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/decode.cpp +17 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scrypted/libav",
3
- "version": "1.0.20",
3
+ "version": "1.0.22",
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
@@ -50,6 +50,20 @@ Napi::Value set_console_callback(const Napi::CallbackInfo &info)
50
50
  return env.Null();
51
51
  }
52
52
 
53
+ void printAVError(int errnum)
54
+ {
55
+ char errbuf[256];
56
+
57
+ // Convert the error code to a string
58
+ if (av_strerror(errnum, errbuf, sizeof(errbuf)) < 0)
59
+ {
60
+ printf("Unknown error code: %d", errnum);
61
+ return;
62
+ }
63
+
64
+ printf("Error: %s\n", errbuf);
65
+ }
66
+
53
67
  class ReadFrameWorker : public Napi::AsyncWorker
54
68
  {
55
69
  public:
@@ -86,6 +100,7 @@ public:
86
100
  {
87
101
  if (packet->stream_index == videoStreamIndex)
88
102
  {
103
+ printf("av packet size: %d\n", packet->size);
89
104
  if ((ret = avcodec_send_packet(codecContext, packet)) == 0)
90
105
  {
91
106
  if ((ret = avcodec_receive_frame(codecContext, frame)) == 0)
@@ -96,12 +111,12 @@ public:
96
111
  }
97
112
  else
98
113
  {
99
- fprintf(stderr, "Error while receiving a frame from the decoder: %d\n", ret);
114
+ printAVError(ret);
100
115
  }
101
116
  }
102
117
  else
103
118
  {
104
- fprintf(stderr, "Error while sending a packet to the decoder: %d\n", ret);
119
+ printAVError(ret);
105
120
  }
106
121
  }
107
122
  av_packet_unref(packet); // Reset the packet for the next frame