pup-recorder 0.3.0 → 0.3.2

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.
@@ -1,8 +1,10 @@
1
1
  import { AV_SAMPLE_FMT_FLT } from 'node-av/constants';
2
2
  import { AV_SAMPLE_FMT_FLTP } from 'node-av/constants';
3
+ import { AVColorRange } from 'node-av/constants';
3
4
  import { AVPixelFormat } from 'node-av/constants';
4
5
  import { BrowserWindow } from 'electron';
5
6
  import { ChildProcess } from 'child_process';
7
+ import { Codec } from 'node-av';
6
8
  import { CodecContext } from 'node-av';
7
9
  import type { Debugger } from 'electron';
8
10
  import { EventEmitter } from 'events';
@@ -20,6 +22,9 @@ import { SpawnOptions } from 'child_process';
20
22
  import { Stream } from 'node-av';
21
23
  import z from 'zod';
22
24
 
25
+ /** Insert emulation prevention bytes (00 00 03) for Annex B compliance. */
26
+ export declare function addEmulationPrevention(nal: Buffer): Buffer;
27
+
23
28
  export declare function advanceVirtualTime(cdp: Debugger, budget: number): Promise<void>;
24
29
 
25
30
  export declare const ANNEX_B_START_CODE: Buffer<ArrayBuffer>;
@@ -67,31 +72,40 @@ export declare interface AudioEncoderOptions {
67
72
  muxer: FormatMuxer;
68
73
  }
69
74
 
75
+ export declare class BitReader {
76
+ private _bits;
77
+ pos: number;
78
+ constructor(data: Buffer);
79
+ get bits(): number[];
80
+ read(n: number): number;
81
+ readUe(): number;
82
+ }
83
+
84
+ export declare class BitWriter {
85
+ bits: number[];
86
+ w(val: number, n: number): void;
87
+ flag(val: boolean | number): void;
88
+ ue(val: number): void;
89
+ align(pad: number): void;
90
+ copy(src: number[], start: number, len: number): void;
91
+ }
92
+
93
+ export declare function buildAlphaChannelInfoSEI(): Buffer;
94
+
70
95
  /**
71
- * Build alpha_channel_info SEI message (payloadType=165).
72
- * Layout from x265 SEIAlphaChannelInfo::writeSEI.
96
+ * Build a complete alpha VPS from scratch, using the original NVENC VPS
97
+ * only as a source for the PTL (profile/tier/level) bytes.
98
+ * Matches x265 4.1 ENABLE_ALPHA VPS structure.
73
99
  */
74
- export declare function buildAlphaChannelInfoSEI(): Buffer;
100
+ export declare function buildAlphaVPS(vpsData: Buffer, width: number, height: number): Buffer;
75
101
 
76
102
  export declare function buildRust(): Promise<void>;
77
103
 
78
104
  export declare function buildStegoHTML(targetURL: string, size: Size): string;
79
105
 
80
- /**
81
- * Builds the JS injector that hooks all time-related globals in the target frame.
82
- * In Electron/stego mode (default), guards against running in the top-level frame.
83
- * In Puppeteer mode (skipFrameGuard: true), injects directly into the main document.
84
- * Must be injected via Page.addScriptToEvaluateOnNewDocument AND directly into
85
- * already-loaded frames.
86
- */
87
- export declare function buildTickInjector(opts?: TickInjectorOptions): string;
106
+ export declare function buildTickInjector(): string;
88
107
 
89
- /**
90
- * Build unified extradata: base VPS (patched for alpha) + interleaved SPS/PPS.
91
- * Alpha SPS/PPS follow their base counterparts so the HVCC serializer
92
- * groups them into the same NAL array (required for multi-layer).
93
- */
94
- export declare function buildUnifiedExtradata(baseExtradata: Buffer, alphaExtradata: Buffer): Buffer;
108
+ export declare function buildUnifiedExtradata(opts: UnifiedExtradataOptions): Buffer;
95
109
 
96
110
  export declare const canIUseGPU: Promise<boolean>;
97
111
 
@@ -183,8 +197,6 @@ export declare function doEject(): string;
183
197
 
184
198
  export declare function doProcess(timestampMs: number): string;
185
199
 
186
- export declare function doPuppeteer(source: string, options: RenderOptions, onProgress?: (p: number) => void): Promise<IpcDonePayload>;
187
-
188
200
  export declare function drainPackets(ctx: CodecContext, pkt: Packet, stream: Stream, muxer: FormatMuxer): Promise<void>;
189
201
 
190
202
  export declare function electronOpts(disableGpu: boolean): Promise<string[]>;
@@ -214,7 +226,7 @@ declare interface EncoderPipelineOptions {
214
226
  fps: number;
215
227
  outFile: string;
216
228
  withAudio?: boolean;
217
- disableGpu?: boolean;
229
+ disableHwCodec?: boolean;
218
230
  }
219
231
  export { EncoderPipelineOptions }
220
232
  export { EncoderPipelineOptions as EncoderPipelineOptions_alias_1 }
@@ -294,7 +306,6 @@ export declare interface HwVideoEncoderOptions {
294
306
  muxer: FormatMuxer;
295
307
  }
296
308
 
297
- /** Interleave base and alpha NALs for a single frame. */
298
309
  export declare function interleaveAccessUnits(baseNals: NalUnit[], alphaNals: NalUnit[]): Buffer;
299
310
 
300
311
  export declare interface IpcDonePayload {
@@ -426,6 +437,8 @@ export declare class NvencDualLayerEncoder implements Disposable {
426
437
  private drainInterleaved;
427
438
  }
428
439
 
440
+ export declare function openVideoCtx(opts: VideoCtxOptions, label: string): Promise<CodecContext>;
441
+
429
442
  export declare function packBits(bits: number[]): Buffer;
430
443
 
431
444
  declare function pargs(): string[];
@@ -455,6 +468,7 @@ export { periodical as periodical_alias_1 }
455
468
  declare interface ProcessHandle {
456
469
  process: ChildProcess;
457
470
  wait: Promise<void>;
471
+ kill(): void;
458
472
  }
459
473
  export { ProcessHandle }
460
474
  export { ProcessHandle as ProcessHandle_alias_1 }
@@ -481,9 +495,9 @@ declare const pupDisableGPU: boolean;
481
495
  export { pupDisableGPU }
482
496
  export { pupDisableGPU as pupDisableGPU_alias_1 }
483
497
 
484
- declare const pupExperimentalPuppeteer: boolean;
485
- export { pupExperimentalPuppeteer }
486
- export { pupExperimentalPuppeteer as pupExperimentalPuppeteer_alias_1 }
498
+ declare const pupDisableHwCodec: boolean;
499
+ export { pupDisableHwCodec }
500
+ export { pupDisableHwCodec as pupDisableHwCodec_alias_1 }
487
501
 
488
502
  declare const pupIpcSocket: string | undefined;
489
503
  export { pupIpcSocket }
@@ -517,6 +531,13 @@ declare const pupUseInnerProxy: boolean;
517
531
  export { pupUseInnerProxy }
518
532
  export { pupUseInnerProxy as pupUseInnerProxy_alias_1 }
519
533
 
534
+ declare const pupWindowTolerant: boolean;
535
+ export { pupWindowTolerant }
536
+ export { pupWindowTolerant as pupWindowTolerant_alias_1 }
537
+
538
+ /** Remove emulation prevention bytes (00 00 03 → 00 00) from RBSP. */
539
+ export declare function removeEmulationPrevention(data: Buffer): Buffer;
540
+
520
541
  export declare function render(writer: IpcWriter, source: string, options: RenderOptions): Promise<IpcDonePayload>;
521
542
 
522
543
  declare type RenderOptions = z.infer<typeof RenderSchema>;
@@ -542,6 +563,8 @@ declare const RenderSchema: z.ZodObject<{
542
563
  useInnerProxy: z.ZodBoolean;
543
564
  deterministic: z.ZodBoolean;
544
565
  disableGpu: z.ZodBoolean;
566
+ disableHwCodec: z.ZodBoolean;
567
+ windowTolerant: z.ZodBoolean;
545
568
  }, z.core.$strip>;
546
569
  export { RenderSchema }
547
570
  export { RenderSchema as RenderSchema_alias_1 }
@@ -576,17 +599,19 @@ export declare function splitNalUnits(bitstream: Buffer): NalUnit[];
576
599
 
577
600
  export declare function startStego(cdp: Debugger): Promise<any>;
578
601
 
602
+ export declare const STEGO_TICK_CHANNEL = "stego-tick";
603
+
579
604
  export declare function stopStego(cdp: Debugger): Promise<any>;
580
605
 
581
606
  export declare const TICK_SYMBOL = "__pup_tick__";
582
607
 
583
- export declare interface TickInjectorOptions {
584
- /**
585
- * When true, skips the top-frame guard so the injector runs in the main document.
586
- * Required for Puppeteer mode where the page is loaded directly (no stego iframe wrapper).
587
- * Default: false (Electron/stego mode — only inject in iframes).
588
- */
589
- skipFrameGuard?: boolean;
608
+ export declare function tickStego(cdp: Debugger, ms: number): Promise<any>;
609
+
610
+ export declare interface UnifiedExtradataOptions {
611
+ baseExtradata: Buffer;
612
+ alphaExtradata: Buffer;
613
+ width: number;
614
+ height: number;
590
615
  }
591
616
 
592
617
  export declare function unsetInterceptor(window: BrowserWindow): void;
@@ -595,6 +620,18 @@ declare function useRetry<Args extends any[], Ret>({ fn, maxAttempts, timeout }:
595
620
  export { useRetry }
596
621
  export { useRetry as useRetry_alias_1 }
597
622
 
623
+ export declare interface VideoCtxOptions {
624
+ codec: Codec;
625
+ width: number;
626
+ height: number;
627
+ fps: number;
628
+ bitrate: number;
629
+ pixelFormat: AVPixelFormat;
630
+ codecTag?: string;
631
+ colorRange?: AVColorRange;
632
+ options?: Record<string, string>;
633
+ }
634
+
598
635
  declare class VideoEncoder_2 implements Disposable {
599
636
  private readonly _ctx;
600
637
  private readonly _pkt;
@@ -615,7 +652,6 @@ export declare interface VideoEncoderOptions {
615
652
  fps: number;
616
653
  codecName: FFVideoEncoder;
617
654
  codecTag?: string;
618
- globalHeader: boolean;
619
655
  codecOpts: Record<string, string>;
620
656
  bitrate: number;
621
657
  pixelFormat: AVPixelFormat;
@@ -627,7 +663,7 @@ export declare interface VideoFactoryOptions {
627
663
  height: number;
628
664
  fps: number;
629
665
  bitrate?: number;
630
- disableGpu?: boolean;
666
+ disableHwCodec?: boolean;
631
667
  }
632
668
 
633
669
  export declare interface VideoSetup {
@@ -668,6 +704,7 @@ export declare interface WindowOptions {
668
704
  onCreated?: (window: BrowserWindow) => Promise<void>;
669
705
  renderer: RenderOptions;
670
706
  warmup?: boolean;
707
+ tolerant?: boolean;
671
708
  }
672
709
 
673
710
  export { }