@scrypted/libav 1.0.172 → 1.0.173
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 +1 -1
- package/.vscode/launch.json +0 -23
- package/.vscode/settings.json +0 -32
- package/darwin.md +0 -24
- package/src/bsf.cpp +0 -213
- package/src/bsf.h +0 -35
- package/src/build-ffmpeg-darwin.sh +0 -13
- package/src/build-ffmpeg-linux.sh +0 -52
- package/src/build-ffmpeg-msys.sh +0 -41
- package/src/build-ffmpeg-windows.bat +0 -8
- package/src/codeccontext.cpp +0 -602
- package/src/codeccontext.h +0 -50
- package/src/error.cpp +0 -33
- package/src/error.h +0 -19
- package/src/ffmpeg-graphparser.cpp +0 -302
- package/src/filter.cpp +0 -487
- package/src/filter.h +0 -37
- package/src/flags.ts +0 -63
- package/src/formatcontext.cpp +0 -899
- package/src/formatcontext.h +0 -47
- package/src/frame.cpp +0 -667
- package/src/frame.h +0 -55
- package/src/index.ts +0 -356
- package/src/packet.cpp +0 -182
- package/src/packet.h +0 -42
- package/src/pkgconfig/glslang.pc +0 -10
- package/src/profiles.ts +0 -108
- package/src/tsconfig.json +0 -26
- package/tsconfig.json +0 -26
package/src/frame.h
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
|
|
3
|
-
#include <napi.h>
|
|
4
|
-
extern "C"
|
|
5
|
-
{
|
|
6
|
-
#include <libavutil/frame.h>
|
|
7
|
-
#include <libavutil/pixdesc.h>
|
|
8
|
-
#include <libavcodec/avcodec.h>
|
|
9
|
-
#include <libavformat/avformat.h>
|
|
10
|
-
#include <libavformat/avformat.h>
|
|
11
|
-
#include <libavutil/hwcontext.h>
|
|
12
|
-
#include <libavutil/frame.h>
|
|
13
|
-
#include <libavfilter/buffersink.h>
|
|
14
|
-
#include <libavfilter/buffersrc.h>
|
|
15
|
-
#include <libavfilter/avfilter.h>
|
|
16
|
-
#include <libavutil/opt.h>
|
|
17
|
-
#include <libavutil/imgutils.h>
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
class AVFrameObject : public Napi::ObjectWrap<AVFrameObject>
|
|
21
|
-
{
|
|
22
|
-
public:
|
|
23
|
-
static Napi::Object Init(Napi::Env env, Napi::Object exports);
|
|
24
|
-
AVFrameObject(const Napi::CallbackInfo &info);
|
|
25
|
-
~AVFrameObject(); // Explicitly declare the destructor
|
|
26
|
-
|
|
27
|
-
// Factory method to create an instance from C++
|
|
28
|
-
static Napi::Object NewInstance(Napi::Env env, AVFrame *frame);
|
|
29
|
-
AVFrame *frame_;
|
|
30
|
-
|
|
31
|
-
private:
|
|
32
|
-
static Napi::FunctionReference constructor;
|
|
33
|
-
Napi::Value GetWidth(const Napi::CallbackInfo &info);
|
|
34
|
-
Napi::Value GetHeight(const Napi::CallbackInfo &info);
|
|
35
|
-
Napi::Value GetPixelFormat(const Napi::CallbackInfo &info);
|
|
36
|
-
Napi::Value GetTimeBaseNum(const Napi::CallbackInfo &info);
|
|
37
|
-
Napi::Value GetTimeBaseDen(const Napi::CallbackInfo &info);
|
|
38
|
-
void SetTimeBaseNum(const Napi::CallbackInfo &info, const Napi::Value &value);
|
|
39
|
-
void SetTimeBaseDen(const Napi::CallbackInfo &info, const Napi::Value &value);
|
|
40
|
-
Napi::Value GetPTS(const Napi::CallbackInfo &info);
|
|
41
|
-
void SetPTS(const Napi::CallbackInfo &info, const Napi::Value &value);
|
|
42
|
-
Napi::Value GetDTS(const Napi::CallbackInfo &info);
|
|
43
|
-
void SetDTS(const Napi::CallbackInfo &info, const Napi::Value &value);
|
|
44
|
-
Napi::Value GetHardware(const Napi::CallbackInfo &info);
|
|
45
|
-
Napi::Value GetSoftware(const Napi::CallbackInfo &info);
|
|
46
|
-
Napi::Value GetFlags(const Napi::CallbackInfo &info);
|
|
47
|
-
void SetFlags(const Napi::CallbackInfo &info, const Napi::Value &value);
|
|
48
|
-
Napi::Value GetPictType(const Napi::CallbackInfo &info);
|
|
49
|
-
void SetPictType(const Napi::CallbackInfo &info, const Napi::Value &value);
|
|
50
|
-
|
|
51
|
-
Napi::Value Destroy(const Napi::CallbackInfo &info);
|
|
52
|
-
Napi::Value CreateEncoder(const Napi::CallbackInfo &info);
|
|
53
|
-
Napi::Value ToBuffer(const Napi::CallbackInfo &info);
|
|
54
|
-
Napi::Value FromBuffer(const Napi::CallbackInfo &info);
|
|
55
|
-
};
|
package/src/index.ts
DELETED
|
@@ -1,356 +0,0 @@
|
|
|
1
|
-
import detectLibc from 'detect-libc';
|
|
2
|
-
import { once } from 'events';
|
|
3
|
-
import { https } from 'follow-redirects';
|
|
4
|
-
import fs from 'fs';
|
|
5
|
-
import { IncomingMessage } from 'http';
|
|
6
|
-
import path from 'path';
|
|
7
|
-
import { x as tarx } from 'tar';
|
|
8
|
-
import packageJson from '../package.json';
|
|
9
|
-
import { AVPictureType } from './flags';
|
|
10
|
-
export * from './flags';
|
|
11
|
-
export * as Profile from './profiles';
|
|
12
|
-
|
|
13
|
-
let addon: any;
|
|
14
|
-
|
|
15
|
-
export function isLoaded() {
|
|
16
|
-
return !!addon;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function getReleasePath(installPath: string) {
|
|
20
|
-
return path.join(installPath, 'build/Release');
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const packagePath = path.join(__dirname, '..');
|
|
24
|
-
export function getAddonPath(installPath = packagePath) {
|
|
25
|
-
return path.join(getReleasePath(installPath), 'addon.node');
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export function getFFmpegPath(installPath = packagePath) {
|
|
29
|
-
return path.join(getReleasePath(installPath), process.platform === 'win32' ? 'ffmpeg.exe' : 'ffmpeg');
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export function loadAddon(addonPath = getAddonPath(), nr: NodeRequire = require) {
|
|
33
|
-
if (isLoaded())
|
|
34
|
-
return addon;
|
|
35
|
-
addon = nr(addonPath);
|
|
36
|
-
return addon;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
let installing: Promise<void> | undefined;
|
|
40
|
-
export async function install(installPath = packagePath, nr: NodeRequire | null = require) {
|
|
41
|
-
const addonPath = getAddonPath(installPath);
|
|
42
|
-
if (!nr) {
|
|
43
|
-
if (fs.existsSync(addonPath))
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
if (isLoaded())
|
|
48
|
-
return;
|
|
49
|
-
|
|
50
|
-
if (installing)
|
|
51
|
-
return installing;
|
|
52
|
-
|
|
53
|
-
try {
|
|
54
|
-
loadAddon(addonPath, nr);
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
catch (e) {
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
installing = (async () => {
|
|
62
|
-
await downloadAddon(installPath);
|
|
63
|
-
if (!nr)
|
|
64
|
-
return;
|
|
65
|
-
loadAddon(addonPath, nr);
|
|
66
|
-
})()
|
|
67
|
-
.finally(() => {
|
|
68
|
-
installing = undefined;
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
return installing;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export async function downloadAddon(installPath?: string) {
|
|
75
|
-
const cwd = installPath || process.cwd();
|
|
76
|
-
await fs.promises.mkdir(cwd, { recursive: true });
|
|
77
|
-
const buildPath = path.join(cwd, 'build');
|
|
78
|
-
const extractPath = path.join(cwd, '.extract');
|
|
79
|
-
try {
|
|
80
|
-
await fs.promises.rm(extractPath, { recursive: true, force: true });
|
|
81
|
-
}
|
|
82
|
-
catch (e) {
|
|
83
|
-
const oldExtractPath = path.join(cwd, '.extract-old');
|
|
84
|
-
fs.promises.rm(oldExtractPath, { recursive: true, force: true });
|
|
85
|
-
await fs.promises.rename(extractPath, oldExtractPath);
|
|
86
|
-
}
|
|
87
|
-
await fs.promises.mkdir(extractPath, { recursive: true });
|
|
88
|
-
await fs.promises.rm(buildPath, { recursive: true, force: true });
|
|
89
|
-
const binaryUrl = getBinaryUrl();
|
|
90
|
-
const r = https.get(binaryUrl, {
|
|
91
|
-
family: 4,
|
|
92
|
-
});
|
|
93
|
-
const [response] = await once(r, 'response') as [IncomingMessage];
|
|
94
|
-
if (!response.statusCode || (response.statusCode < 200 && response.statusCode >= 300))
|
|
95
|
-
throw new Error(`Failed to download libav binary: ${response.statusCode}`);
|
|
96
|
-
const t = response.pipe(tarx({
|
|
97
|
-
cwd: extractPath,
|
|
98
|
-
}));
|
|
99
|
-
await once(t, 'end');
|
|
100
|
-
await fs.promises.rename(path.join(extractPath, 'build'), buildPath);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
export interface AVFrame extends AVTimeBase {
|
|
104
|
-
readonly width: number;
|
|
105
|
-
readonly height: number;
|
|
106
|
-
readonly pixelFormat: string;
|
|
107
|
-
readonly hardwareDeviceType: string;
|
|
108
|
-
readonly softwareFormat: string;
|
|
109
|
-
pictType: AVPictureType;
|
|
110
|
-
|
|
111
|
-
flags: number;
|
|
112
|
-
timeBaseNum: number;
|
|
113
|
-
timeBaseDen: number;
|
|
114
|
-
pts: number;
|
|
115
|
-
dts: number;
|
|
116
|
-
|
|
117
|
-
[Symbol.dispose](): void;
|
|
118
|
-
destroy(): void;
|
|
119
|
-
toBuffer(): Buffer;
|
|
120
|
-
fromBuffer(buffer: Buffer): void;
|
|
121
|
-
createEncoder(options: {
|
|
122
|
-
encoder: string,
|
|
123
|
-
bitrate: number,
|
|
124
|
-
minRate?: number;
|
|
125
|
-
maxRate?: number,
|
|
126
|
-
bufSize?: number,
|
|
127
|
-
timeBase: AVTimeBase,
|
|
128
|
-
framerate?: AVTimeBase,
|
|
129
|
-
flags?: number,
|
|
130
|
-
opts?: {
|
|
131
|
-
[key: string]: string | number,
|
|
132
|
-
},
|
|
133
|
-
profile?: number;
|
|
134
|
-
gopSize?: number;
|
|
135
|
-
keyIntMin?: number;
|
|
136
|
-
}): AVCodecContext;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
export interface AVFilter {
|
|
140
|
-
[Symbol.dispose](): void;
|
|
141
|
-
destroy(): void;
|
|
142
|
-
sendCommand(target: string, command: string, arg: string): void;
|
|
143
|
-
addFrame(frame: AVFrame, index?: number): void;
|
|
144
|
-
getFrame(index?: number): AVFrame;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
export interface AVBitstreamFilter {
|
|
148
|
-
[Symbol.dispose](): void;
|
|
149
|
-
destroy(): void;
|
|
150
|
-
setOption(name: string, value: string): void;
|
|
151
|
-
sendPacket(packet: AVPacket): void;
|
|
152
|
-
receivePacket(): AVPacket;
|
|
153
|
-
copyParameters(formatContext: AVFormatContext, streamIndex: number): void;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
export interface AVPacket {
|
|
157
|
-
readonly streamIndex: number;
|
|
158
|
-
flags: number;
|
|
159
|
-
readonly size: number;
|
|
160
|
-
pts: number;
|
|
161
|
-
dts: number;
|
|
162
|
-
readonly duration: number;
|
|
163
|
-
|
|
164
|
-
[Symbol.dispose](): void;
|
|
165
|
-
getData(): Buffer;
|
|
166
|
-
destroy(): void;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
export interface AVCodecContext extends AVTimeBase {
|
|
170
|
-
readonly hardwareDevice: string;
|
|
171
|
-
/**
|
|
172
|
-
* The pixel format of the output frames.
|
|
173
|
-
* May not be available until the first frame is read.
|
|
174
|
-
*/
|
|
175
|
-
readonly pixelFormat: string;
|
|
176
|
-
readonly hardwarePixelFormat: string;
|
|
177
|
-
readonly vendorInfo: Record<string, any>;
|
|
178
|
-
keyIntMin: number;
|
|
179
|
-
gopSize: number;
|
|
180
|
-
|
|
181
|
-
[Symbol.dispose](): void;
|
|
182
|
-
destroy(): void;
|
|
183
|
-
sendPacket(packet: AVPacket): Promise<boolean>;
|
|
184
|
-
receiveFrame(): Promise<AVFrame>;
|
|
185
|
-
sendFrame(packet: AVFrame): Promise<boolean>;
|
|
186
|
-
receivePacket(): Promise<AVPacket>;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
export interface AVStream extends AVTimeBase {
|
|
190
|
-
readonly index: number;
|
|
191
|
-
readonly codec: string;
|
|
192
|
-
readonly type: string;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
export interface AVTimeBase {
|
|
196
|
-
readonly timeBaseNum: number,
|
|
197
|
-
readonly timeBaseDen: number,
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
export interface AVFormatContext {
|
|
201
|
-
readonly metadata: any;
|
|
202
|
-
readonly streams: AVStream[];
|
|
203
|
-
|
|
204
|
-
[Symbol.dispose](): void;
|
|
205
|
-
open(input: string): void;
|
|
206
|
-
createDecoder(streamIndex: number, hardwareDevice?: string, decoder?: string, deviceName?: string): AVCodecContext;
|
|
207
|
-
readFrame(): Promise<AVPacket>;
|
|
208
|
-
receiveFrame(streamIndex: number, codecContext: AVCodecContext): Promise<AVFrame|AVPacket>;
|
|
209
|
-
create(format: string, callback: (buffer: Buffer) => void): void;
|
|
210
|
-
newStream(options: {
|
|
211
|
-
codecContext?: AVCodecContext,
|
|
212
|
-
formatContext?: AVFormatContext,
|
|
213
|
-
streamIndex?: number,
|
|
214
|
-
}): number;
|
|
215
|
-
writeFrame(streamIndex: number, packet: AVPacket): void;
|
|
216
|
-
createSDP(): string;
|
|
217
|
-
close(): void;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
export function setAVLogLevel(level: 'quiet' | 'panic' | 'fatal' | 'error' | 'warning' | 'info' | 'verbose' | 'debug' | 'trace') {
|
|
221
|
-
loadAddon().setLogLevel(level);
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
export function createAVFormatContext(): AVFormatContext {
|
|
225
|
-
return new (loadAddon().AVFormatContext)();
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
export function createAVFilter(options: {
|
|
229
|
-
filter: string,
|
|
230
|
-
frames: {
|
|
231
|
-
frame: AVFrame,
|
|
232
|
-
timeBase: AVTimeBase,
|
|
233
|
-
}[],
|
|
234
|
-
threadCount?: number,
|
|
235
|
-
hardwareDevice?: string,
|
|
236
|
-
hardwareDeviceName?: string,
|
|
237
|
-
hardwareDeviceFrame?: AVFrame;
|
|
238
|
-
// outCount defaults to 1
|
|
239
|
-
outCount?: number,
|
|
240
|
-
}): AVFilter {
|
|
241
|
-
return new (loadAddon().AVFilter)(options);
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
export function createAVFrame(
|
|
245
|
-
width: number,
|
|
246
|
-
height: number,
|
|
247
|
-
pixelFormat: string,
|
|
248
|
-
fillBlack = true,
|
|
249
|
-
): AVFrame {
|
|
250
|
-
return new (loadAddon().AVFrame)(width, height, pixelFormat, fillBlack);
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
export function createAVBitstreamFilter(filter: string): AVBitstreamFilter {
|
|
254
|
-
return new (loadAddon().AVBitstreamFilter)(filter);
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
export function getBinaryUrl() {
|
|
258
|
-
const libc = process.env.LIBC || process.env.npm_config_libc ||
|
|
259
|
-
(detectLibc.isNonGlibcLinuxSync() && detectLibc.familySync()) || ''
|
|
260
|
-
|
|
261
|
-
const { name, version } = packageJson;
|
|
262
|
-
const binaryName = name.replace(/^@[a-zA-Z0-9_\-.~]+\//, '')
|
|
263
|
-
|
|
264
|
-
const abi = process.versions.modules;
|
|
265
|
-
const runtime = process.env.npm_config_runtime || 'node';
|
|
266
|
-
const { platform, arch } = process;
|
|
267
|
-
const packageName = `${binaryName}-v${version}-${runtime}-v${abi}-${platform}${libc}-${arch}.tar.gz`;
|
|
268
|
-
|
|
269
|
-
const url = `https://github.com/scryptedapp/libav/releases/download/v${version}/${packageName}`;
|
|
270
|
-
|
|
271
|
-
return url;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
async function encodeJpeg(softwareFrame: AVFrame, quality: number) {
|
|
275
|
-
using encoder = softwareFrame.createEncoder({
|
|
276
|
-
encoder: 'mjpeg',
|
|
277
|
-
bitrate: 2000000,
|
|
278
|
-
timeBase: {
|
|
279
|
-
timeBaseNum: 1,
|
|
280
|
-
timeBaseDen: 25,
|
|
281
|
-
},
|
|
282
|
-
opts: {
|
|
283
|
-
quality,
|
|
284
|
-
qmin: quality,
|
|
285
|
-
qmax: quality,
|
|
286
|
-
},
|
|
287
|
-
});
|
|
288
|
-
|
|
289
|
-
const sent = await encoder.sendFrame(softwareFrame);
|
|
290
|
-
if (!sent)
|
|
291
|
-
throw new Error('sendFrame failed');
|
|
292
|
-
|
|
293
|
-
using transcodePacket = await encoder.receivePacket();
|
|
294
|
-
if (!transcodePacket)
|
|
295
|
-
throw new Error('receivePacket needs more frames');
|
|
296
|
-
|
|
297
|
-
return transcodePacket.getData();
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
export function createSdp(formatContexts: AVFormatContext[]): string {
|
|
301
|
-
return loadAddon().createSdp(formatContexts);
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
export async function toJpeg(frame: AVFrame, quality: number) {
|
|
305
|
-
if (frame.pixelFormat === 'yuvj420p')
|
|
306
|
-
return await encodeJpeg(frame, quality);
|
|
307
|
-
|
|
308
|
-
let filterString = `scale,format=yuvj420p`;
|
|
309
|
-
if (frame.hardwareDeviceType)
|
|
310
|
-
filterString = `hwdownload,format=${frame.softwareFormat},${filterString}`;
|
|
311
|
-
|
|
312
|
-
using filter = createAVFilter({
|
|
313
|
-
filter: filterString,
|
|
314
|
-
frames: [
|
|
315
|
-
{
|
|
316
|
-
frame,
|
|
317
|
-
timeBase: {
|
|
318
|
-
timeBaseNum: 1,
|
|
319
|
-
timeBaseDen: 25,
|
|
320
|
-
},
|
|
321
|
-
}
|
|
322
|
-
],
|
|
323
|
-
});
|
|
324
|
-
|
|
325
|
-
filter.addFrame(frame);
|
|
326
|
-
using softwareFrame = filter.getFrame();
|
|
327
|
-
softwareFrame.pts = 0;
|
|
328
|
-
softwareFrame.dts = 0;
|
|
329
|
-
|
|
330
|
-
return await encodeJpeg(softwareFrame, quality);
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
export async function toBuffer(frame: AVFrame) {
|
|
334
|
-
if (!frame.hardwareDeviceType)
|
|
335
|
-
return frame.toBuffer();
|
|
336
|
-
|
|
337
|
-
const filterString = `hwdownload,format=${frame.softwareFormat}`;
|
|
338
|
-
using filter = createAVFilter({
|
|
339
|
-
filter: filterString,
|
|
340
|
-
frames: [
|
|
341
|
-
{
|
|
342
|
-
frame,
|
|
343
|
-
timeBase: {
|
|
344
|
-
timeBaseNum: 1,
|
|
345
|
-
timeBaseDen: 25,
|
|
346
|
-
},
|
|
347
|
-
}
|
|
348
|
-
],
|
|
349
|
-
});
|
|
350
|
-
|
|
351
|
-
filter.addFrame(frame);
|
|
352
|
-
using softwareFrame = filter.getFrame();
|
|
353
|
-
return softwareFrame.toBuffer();
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
export const version: string = packageJson.version;
|
package/src/packet.cpp
DELETED
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
#include <napi.h>
|
|
2
|
-
extern "C"
|
|
3
|
-
{
|
|
4
|
-
#include <libavcodec/avcodec.h>
|
|
5
|
-
#include <libavformat/avformat.h>
|
|
6
|
-
#include <libavutil/hwcontext.h>
|
|
7
|
-
#include <libavutil/frame.h>
|
|
8
|
-
#include <libavfilter/buffersink.h>
|
|
9
|
-
#include <libavfilter/buffersrc.h>
|
|
10
|
-
#include <libavfilter/avfilter.h>
|
|
11
|
-
#include <libavutil/opt.h>
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
#include <thread>
|
|
15
|
-
#include <v8.h>
|
|
16
|
-
|
|
17
|
-
#include "packet.h"
|
|
18
|
-
|
|
19
|
-
Napi::FunctionReference AVPacketObject::constructor;
|
|
20
|
-
|
|
21
|
-
Napi::Object AVPacketObject::Init(Napi::Env env, Napi::Object exports)
|
|
22
|
-
{
|
|
23
|
-
Napi::HandleScope scope(env);
|
|
24
|
-
|
|
25
|
-
Napi::Function func = DefineClass(env, "AVPacketObject", {
|
|
26
|
-
AVPacketObject::InstanceAccessor("flags", &AVPacketObject::GetFlags, &AVPacketObject::SetFlags),
|
|
27
|
-
AVPacketObject::InstanceAccessor("pts", &AVPacketObject::GetPTS, &AVPacketObject::SetPTS),
|
|
28
|
-
AVPacketObject::InstanceAccessor("dts", &AVPacketObject::GetDTS, &AVPacketObject::SetDTS),
|
|
29
|
-
AVPacketObject::InstanceAccessor("duration", &AVPacketObject::GetDuration, nullptr),
|
|
30
|
-
AVPacketObject::InstanceAccessor("size", &AVPacketObject::GetSize, nullptr),
|
|
31
|
-
AVPacketObject::InstanceAccessor("streamIndex", &AVPacketObject::GetStreamIndex, nullptr),
|
|
32
|
-
InstanceMethod(Napi::Symbol::WellKnown(env, "dispose"), &AVPacketObject::Destroy),
|
|
33
|
-
InstanceMethod("clone", &AVPacketObject::Clone),
|
|
34
|
-
InstanceMethod("destroy", &AVPacketObject::Destroy),
|
|
35
|
-
InstanceMethod("getData", &AVPacketObject::GetData),
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
constructor = Napi::Persistent(func);
|
|
39
|
-
constructor.SuppressDestruct();
|
|
40
|
-
return exports;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
Napi::Object AVPacketObject::NewInstance(Napi::Env env, AVPacket *packet)
|
|
44
|
-
{
|
|
45
|
-
Napi::Object obj = constructor.New({});
|
|
46
|
-
AVPacketObject *avPacketObject = Napi::ObjectWrap<AVPacketObject>::Unwrap(obj);
|
|
47
|
-
avPacketObject->packet = packet;
|
|
48
|
-
return obj;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
AVPacketObject::AVPacketObject(const Napi::CallbackInfo &info)
|
|
52
|
-
: Napi::ObjectWrap<AVPacketObject>(info)
|
|
53
|
-
{
|
|
54
|
-
packet = nullptr;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
AVPacketObject::~AVPacketObject()
|
|
58
|
-
{
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
Napi::Value AVPacketObject::Clone(const Napi::CallbackInfo &info)
|
|
62
|
-
{
|
|
63
|
-
if (!packet)
|
|
64
|
-
{
|
|
65
|
-
return info.Env().Undefined();
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
AVPacket *newPacket = av_packet_alloc();
|
|
69
|
-
if (!newPacket)
|
|
70
|
-
{
|
|
71
|
-
Napi::TypeError::New(info.Env(), "Failed to allocate new AVPacket").ThrowAsJavaScriptException();
|
|
72
|
-
return info.Env().Undefined();
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
int ret = av_packet_ref(newPacket, packet);
|
|
76
|
-
if (ret < 0)
|
|
77
|
-
{
|
|
78
|
-
av_packet_free(&newPacket);
|
|
79
|
-
Napi::TypeError::New(info.Env(), "Failed to reference AVPacket").ThrowAsJavaScriptException();
|
|
80
|
-
return info.Env().Undefined();
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
return NewInstance(info.Env(), newPacket);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
Napi::Value AVPacketObject::Destroy(const Napi::CallbackInfo &info)
|
|
87
|
-
{
|
|
88
|
-
if (packet)
|
|
89
|
-
{
|
|
90
|
-
av_packet_free(&packet);
|
|
91
|
-
packet = nullptr;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return info.Env().Undefined();
|
|
95
|
-
}
|
|
96
|
-
Napi::Value AVPacketObject::GetFlags(const Napi::CallbackInfo &info)
|
|
97
|
-
{
|
|
98
|
-
return Napi::Number::New(info.Env(), packet ? packet->flags : 0);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
void AVPacketObject::SetFlags(const Napi::CallbackInfo &info, const Napi::Value &value)
|
|
102
|
-
{
|
|
103
|
-
if (!packet)
|
|
104
|
-
{
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
if (!value.IsNumber())
|
|
109
|
-
{
|
|
110
|
-
Napi::TypeError::New(info.Env(), "Number expected for flags").ThrowAsJavaScriptException();
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
packet->flags = value.As<Napi::Number>().Int32Value();
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
Napi::Value AVPacketObject::GetPTS(const Napi::CallbackInfo &info)
|
|
118
|
-
{
|
|
119
|
-
return Napi::Number::New(info.Env(), packet ? packet->pts : 0);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
void AVPacketObject::SetPTS(const Napi::CallbackInfo &info, const Napi::Value &value)
|
|
123
|
-
{
|
|
124
|
-
if (!packet)
|
|
125
|
-
{
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
if (!value.IsNumber())
|
|
130
|
-
{
|
|
131
|
-
Napi::TypeError::New(info.Env(), "Number expected for pts").ThrowAsJavaScriptException();
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
packet->pts = value.As<Napi::Number>().Int64Value();
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
Napi::Value AVPacketObject::GetDTS(const Napi::CallbackInfo &info)
|
|
139
|
-
{
|
|
140
|
-
return Napi::Number::New(info.Env(), packet ? packet->dts : 0);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
void AVPacketObject::SetDTS(const Napi::CallbackInfo &info, const Napi::Value &value)
|
|
144
|
-
{
|
|
145
|
-
if (!packet)
|
|
146
|
-
{
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
if (!value.IsNumber())
|
|
151
|
-
{
|
|
152
|
-
Napi::TypeError::New(info.Env(), "Number expected for dts").ThrowAsJavaScriptException();
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
packet->dts = value.As<Napi::Number>().Int64Value();
|
|
157
|
-
}
|
|
158
|
-
Napi::Value AVPacketObject::GetDuration(const Napi::CallbackInfo &info)
|
|
159
|
-
{
|
|
160
|
-
return Napi::Number::New(info.Env(), packet ? packet->duration : 0);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
Napi::Value AVPacketObject::GetSize(const Napi::CallbackInfo &info)
|
|
164
|
-
{
|
|
165
|
-
return Napi::Number::New(info.Env(), packet ? packet->size : 0);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
Napi::Value AVPacketObject::GetData(const Napi::CallbackInfo &info)
|
|
169
|
-
{
|
|
170
|
-
if (!packet || !packet->data)
|
|
171
|
-
{
|
|
172
|
-
return info.Env().Undefined();
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
Napi::Buffer<uint8_t> buffer = Napi::Buffer<uint8_t>::Copy(info.Env(), packet->data, packet->size);
|
|
176
|
-
return buffer;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
Napi::Value AVPacketObject::GetStreamIndex(const Napi::CallbackInfo &info)
|
|
180
|
-
{
|
|
181
|
-
return Napi::Number::New(info.Env(), packet ? packet->stream_index : -1);
|
|
182
|
-
}
|
package/src/packet.h
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
|
|
3
|
-
#include <napi.h>
|
|
4
|
-
extern "C"
|
|
5
|
-
{
|
|
6
|
-
#include <libavcodec/avcodec.h>
|
|
7
|
-
#include <libavformat/avformat.h>
|
|
8
|
-
#include <libavutil/hwcontext.h>
|
|
9
|
-
#include <libavutil/frame.h>
|
|
10
|
-
#include <libavfilter/buffersink.h>
|
|
11
|
-
#include <libavfilter/buffersrc.h>
|
|
12
|
-
#include <libavfilter/avfilter.h>
|
|
13
|
-
#include <libavutil/opt.h>
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
#include <thread>
|
|
17
|
-
#include <v8.h>
|
|
18
|
-
|
|
19
|
-
class AVPacketObject : public Napi::ObjectWrap<AVPacketObject>
|
|
20
|
-
{
|
|
21
|
-
public:
|
|
22
|
-
static Napi::FunctionReference constructor;
|
|
23
|
-
static Napi::Object Init(Napi::Env env, Napi::Object exports);
|
|
24
|
-
static Napi::Object NewInstance(Napi::Env env, AVPacket *packet);
|
|
25
|
-
|
|
26
|
-
AVPacketObject(const Napi::CallbackInfo &info);
|
|
27
|
-
~AVPacketObject();
|
|
28
|
-
Napi::Value Clone(const Napi::CallbackInfo &info);
|
|
29
|
-
Napi::Value Destroy(const Napi::CallbackInfo &info);
|
|
30
|
-
Napi::Value GetFlags(const Napi::CallbackInfo &info);
|
|
31
|
-
void SetFlags(const Napi::CallbackInfo &info, const Napi::Value &value);
|
|
32
|
-
Napi::Value GetPTS(const Napi::CallbackInfo &info);
|
|
33
|
-
void SetPTS(const Napi::CallbackInfo &info, const Napi::Value &value);
|
|
34
|
-
Napi::Value GetDTS(const Napi::CallbackInfo &info);
|
|
35
|
-
void SetDTS(const Napi::CallbackInfo &info, const Napi::Value &value);
|
|
36
|
-
Napi::Value GetDuration(const Napi::CallbackInfo &info);
|
|
37
|
-
Napi::Value GetSize(const Napi::CallbackInfo &info);
|
|
38
|
-
Napi::Value GetData(const Napi::CallbackInfo &info);
|
|
39
|
-
Napi::Value GetStreamIndex(const Napi::CallbackInfo &info);
|
|
40
|
-
|
|
41
|
-
AVPacket *packet;
|
|
42
|
-
};
|
package/src/pkgconfig/glslang.pc
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
prefix=/c/VulkanSDK/1.3.280.0
|
|
2
|
-
includedir=${prefix}/Include
|
|
3
|
-
libdir=${prefix}/Lib
|
|
4
|
-
|
|
5
|
-
Name: ffnvcodec
|
|
6
|
-
Description: Vulkan
|
|
7
|
-
Version: 1.3.280
|
|
8
|
-
Cflags: -I${includedir}
|
|
9
|
-
Libs: -L${libdir} -lglslang -lMachineIndependent -lOSDependent -lGenericCodeGen -lSPVRemapper -lSPIRV -lSPIRV-Tools-opt -lSPIRV-Tools -lstdc++ -lmsvcrt
|
|
10
|
-
Libs.private:
|