@scrypted/libav 1.0.1 → 1.0.3

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/lib/index.d.ts ADDED
@@ -0,0 +1,22 @@
1
+ export declare function isAvailable(): boolean;
2
+ export interface AVFrame {
3
+ close(): void;
4
+ width: number;
5
+ height: number;
6
+ format: string;
7
+ toBuffer(): Buffer;
8
+ toJpeg(): Buffer;
9
+ }
10
+ export interface AVFilter {
11
+ destroy(): void;
12
+ setCrop(x: string, y: string, width: string, height: string): void;
13
+ filter(frame: AVFrame): AVFrame;
14
+ }
15
+ export interface AVFormatContext {
16
+ open(input: string, codec: string): void;
17
+ readFrame(): Promise<AVFrame>;
18
+ createFilter(width: number, height: number, filter: string, useHardware: boolean): AVFilter;
19
+ close(): void;
20
+ }
21
+ export declare function setAVLogCallback(callback: (msg: string) => void): void;
22
+ export declare function createAVFormatContext(): AVFormatContext;
package/package.json CHANGED
@@ -1,8 +1,7 @@
1
1
  {
2
2
  "name": "@scrypted/libav",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "dependencies": {
5
- "@types/node": "^22.5.0",
6
5
  "node-addon-api": "^8.1.0",
7
6
  "prebuild-install": "npm:@scrypted/prebuild-install@^7.1.8"
8
7
  },
@@ -11,9 +10,10 @@
11
10
  "url": "git://github.com/scryptedapp/libav.git"
12
11
  },
13
12
  "main": "./lib/index.js",
13
+ "types": "./lib/index.d.ts",
14
14
  "scripts": {
15
15
  "prebuildify-host": "prebuild --strip --include-regex \"\\.node$|spawn-helper$|\\.exe$|\\.dll$|\\.pdb$\"",
16
- "prebuildify-node": "prebuild --strip -t 18.0.0 -t 20.0.0 -t 22.0.0 --include-regex \"\\.node$|spawn-helper$|\\.exe$|\\.dll$|\\.pdb$\"",
16
+ "prebuildify-node": "prebuild --strip -t 20.0.0 -t 22.0.0 --include-regex \"\\.node$|spawn-helper$|\\.exe$|\\.dll$|\\.pdb$\"",
17
17
  "prebuildify-electron": "prebuild --strip -r electron -t 30.0.0 -t 31.0.0 --include-regex \"\\.node$|spawn-helper$|\\.exe$|\\.dll$|\\.pdb$\"",
18
18
  "prebuildify-arm64": "npm run prebuildify-electron -- --arch arm64 && npm run prebuildify-node -- --arch arm64",
19
19
  "prebuildify-x64": "npm run prebuildify-electron -- --arch x64 && npm run prebuildify-node -- --arch x64",
@@ -32,6 +32,7 @@
32
32
  "prepublishOnly": "npm run build"
33
33
  },
34
34
  "devDependencies": {
35
+ "@types/node": "^22.5.0",
35
36
  "node-gyp": "^10.2.0",
36
37
  "prebuild": "^13.0.1",
37
38
  "typescript": "^5.5.4"
package/src/frame.cpp CHANGED
@@ -119,7 +119,7 @@ Napi::Value AVFrameObject::ToJPEG(const Napi::CallbackInfo &info)
119
119
  c->time_base = (AVRational){1, 25};
120
120
 
121
121
  // Set the JPEG quality
122
- int quality = 2; // 1-31, lower is better quality
122
+ int quality = 2; // 1-31, lower is better quality
123
123
  av_opt_set_int(c, "qscale", quality, 0); // Set the quality scale (1-31, lower is better quality)
124
124
  av_opt_set_int(c, "qmin", quality, 0); // Set the minimum quality
125
125
  av_opt_set_int(c, "qmax", quality, 0); // Set the maximum quality
@@ -140,11 +140,9 @@ Napi::Value AVFrameObject::ToJPEG(const Napi::CallbackInfo &info)
140
140
  }
141
141
 
142
142
  AVPacket pkt;
143
- pkt.data = NULL;
143
+ av_init_packet(&pkt);
144
+ pkt.data = NULL; // Packet data will be allocated by the encoder
144
145
  pkt.size = 0;
145
- pkt.pts = AV_NOPTS_VALUE;
146
- pkt.dts = AV_NOPTS_VALUE;
147
- pkt.pos = -1;
148
146
 
149
147
  ret = avcodec_receive_packet(c, &pkt);
150
148
  if (ret < 0)
package/src/tsconfig.json CHANGED
@@ -8,7 +8,8 @@
8
8
  "lib": [
9
9
  "es2015"
10
10
  ],
11
- "strict": true
11
+ "strict": true,
12
+ "declaration": true,
12
13
  },
13
14
  "exclude": [
14
15
  "node_modules",