pup-recorder 0.3.2 → 0.3.4

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/README.md CHANGED
@@ -7,6 +7,8 @@ pup-recorder — record web pages as video
7
7
  ## SYNOPSIS
8
8
 
9
9
  pup source [-W width] [-H height] [-f fps] [-t duration] [-o file] [-a] [-d]
10
+ [--disable-gpu] [--disable-hw-codec] [--window-tolerant]
11
+ [--use-inner-proxy]
10
12
 
11
13
  ## OPTIONS
12
14
 
@@ -14,19 +16,25 @@ pup-recorder — record web pages as video
14
16
  -W, --width <number> default: 1920
15
17
  -H, --height <number> default: 1080
16
18
  -f, --fps <number> default: 30
17
- -t, --duration <number> default: 5
19
+ -t, --duration <number> default: 5 (seconds)
18
20
  -o, --out-file <path> default: output.mp4
19
21
  -a, --with-audio
20
- -d, --deterministic frame-by-frame rendering mode
21
- --use-inner-proxy use Bilibili inner proxy
22
+ -d, --deterministic frame-by-frame via CDP virtual time
23
+ --use-inner-proxy Bilibili inner proxy
24
+ --disable-gpu force SwiftShader software rendering
25
+ --disable-hw-codec software x265 instead of NVENC/VideoToolbox
26
+ --window-tolerant accept dom-ready when did-stop-loading hangs
22
27
 
23
28
  ## ENVIRONMENT
24
29
 
25
- PUP_LOG_LEVEL 0=error 1=warn 2=info 3=debug (default: 2)
26
- PUP_USE_INNER_PROXY 1=on
27
- PUP_DISABLE_GPU 1=on
28
- PUP_DETERMINISTIC 1=on
29
- PUP_EXPERIMENTAL_PUPPETEER 1=on (Linux puppeteer mode)
30
+ PUP_LOG_LEVEL 0=error 1=warn 2=info 3=debug (default: 2)
31
+ PUP_USE_INNER_PROXY 1=on
32
+ PUP_DISABLE_GPU 1=on
33
+ PUP_DISABLE_HW_CODEC 1=on
34
+ PUP_DETERMINISTIC 1=on
35
+ PUP_WINDOW_TOLERANT 1=on
36
+
37
+ CLI flags override environment variables.
30
38
 
31
39
  ## API
32
40
 
@@ -36,8 +44,10 @@ import { pup } from "pup-recorder";
36
44
  const result = await pup(source, {
37
45
  width, height, fps, duration, outFile,
38
46
  withAudio, deterministic, useInnerProxy,
47
+ disableGpu, disableHwCodec, windowTolerant,
39
48
  signal, onProgress,
40
49
  });
50
+ // => { written, jank, outFile, options }
41
51
  ```
42
52
 
43
53
  ## SEE ALSO
@@ -6,7 +6,7 @@ import { BrowserWindow } from 'electron';
6
6
  import { ChildProcess } from 'child_process';
7
7
  import { Codec } from 'node-av';
8
8
  import { CodecContext } from 'node-av';
9
- import type { Debugger } from 'electron';
9
+ import { Debugger } from 'electron';
10
10
  import { EventEmitter } from 'events';
11
11
  import { FFAudioEncoder } from 'node-av/constants';
12
12
  import { FFVideoEncoder } from 'node-av/constants';
@@ -16,10 +16,10 @@ import { HardwareContext } from 'node-av/api';
16
16
  import type { NativeImage } from 'electron';
17
17
  import { Packet } from 'node-av';
18
18
  import { Size } from 'electron';
19
- import { Socket } from 'net';
20
19
  import { SoftwareScaleContext } from 'node-av';
21
20
  import { SpawnOptions } from 'child_process';
22
21
  import { Stream } from 'node-av';
22
+ import type { WebFrameMain } from 'electron';
23
23
  import z from 'zod';
24
24
 
25
25
  /** Insert emulation prevention bytes (00 00 03) for Annex B compliance. */
@@ -103,8 +103,6 @@ export declare function buildRust(): Promise<void>;
103
103
 
104
104
  export declare function buildStegoHTML(targetURL: string, size: Size): string;
105
105
 
106
- export declare function buildTickInjector(): string;
107
-
108
106
  export declare function buildUnifiedExtradata(opts: UnifiedExtradataOptions): Buffer;
109
107
 
110
108
  export declare const canIUseGPU: Promise<boolean>;
@@ -157,10 +155,6 @@ declare class ConcurrencyLimiter {
157
155
  export { ConcurrencyLimiter }
158
156
  export { ConcurrencyLimiter as ConcurrencyLimiter_alias_1 }
159
157
 
160
- export declare function connectIpc(socketPath: string): Promise<IpcWriter>;
161
-
162
- export declare function createIpcServer(socketPath: string): Promise<IpcServer>;
163
-
164
158
  export declare function createStegoURL(src: string, size: Size): string;
165
159
 
166
160
  export declare function createVideoEncoder(opts: VideoFactoryOptions, muxer: FormatMuxer): Promise<VideoSetup>;
@@ -193,9 +187,7 @@ declare const defaultRenderOptions: RenderOptions;
193
187
  export { defaultRenderOptions }
194
188
  export { defaultRenderOptions as defaultRenderOptions_alias_1 }
195
189
 
196
- export declare function doEject(): string;
197
-
198
- export declare function doProcess(timestampMs: number): string;
190
+ export declare function disposeWindow(win: BrowserWindow): Promise<void>;
199
191
 
200
192
  export declare function drainPackets(ctx: CodecContext, pkt: Packet, stream: Stream, muxer: FormatMuxer): Promise<void>;
201
193
 
@@ -315,40 +307,26 @@ export declare interface IpcDonePayload {
315
307
  }
316
308
 
317
309
  export declare const enum IpcMsgType {
318
- PROGRESS = 1,
319
- DONE = 2,
320
- ERROR = 3
310
+ PROGRESS = "progress",
311
+ DONE = "done",
312
+ ERROR = "error"
321
313
  }
322
314
 
323
315
  export declare class IpcReader extends EventEmitter<{
324
316
  progress: [value: number];
325
- message: [type: IpcMsgType, buffer: Buffer];
317
+ message: [msg: Msg];
326
318
  done: [payload: IpcDonePayload];
327
319
  error: [error: Error];
328
320
  close: [];
329
321
  }> {
330
- private readonly _socket;
331
- private _chunks;
332
- private _buffered;
333
- constructor(_socket: Socket);
334
- private onData;
335
- private flush;
336
- private peek;
337
- private consume;
338
- }
339
-
340
- export declare interface IpcServer {
341
- waitForConnection(): Promise<IpcReader>;
342
- close(): void;
322
+ constructor(child: ChildProcess);
343
323
  }
344
324
 
345
325
  export declare class IpcWriter {
346
- private readonly _socket;
347
- constructor(_socket: Socket);
348
326
  writeProgress(value: number): void;
349
- writeError(error: string): void;
350
- writeDone(payload: IpcDonePayload): void;
351
- private write;
327
+ writeError(error: string): Promise<void>;
328
+ writeDone(payload: IpcDonePayload): Promise<void>;
329
+ private send;
352
330
  }
353
331
 
354
332
  export declare function isEmpty(image: NativeImage): boolean;
@@ -404,6 +382,17 @@ export declare function makeFrame(width: number, height: number, pixFmt: AVPixel
404
382
 
405
383
  export declare function makePacket(): Packet;
406
384
 
385
+ declare type Msg = {
386
+ type: IpcMsgType.PROGRESS;
387
+ value: number;
388
+ } | {
389
+ type: IpcMsgType.DONE;
390
+ payload: IpcDonePayload;
391
+ } | {
392
+ type: IpcMsgType.ERROR;
393
+ error: string;
394
+ };
395
+
407
396
  export declare const NAL_HEADER_SIZE = 2;
408
397
 
409
398
  export declare interface NalUnit {
@@ -468,6 +457,7 @@ export { periodical as periodical_alias_1 }
468
457
  declare interface ProcessHandle {
469
458
  process: ChildProcess;
470
459
  wait: Promise<void>;
460
+ get killed(): boolean;
471
461
  kill(): void;
472
462
  }
473
463
  export { ProcessHandle }
@@ -499,10 +489,6 @@ declare const pupDisableHwCodec: boolean;
499
489
  export { pupDisableHwCodec }
500
490
  export { pupDisableHwCodec as pupDisableHwCodec_alias_1 }
501
491
 
502
- declare const pupIpcSocket: string | undefined;
503
- export { pupIpcSocket }
504
- export { pupIpcSocket as pupIpcSocket_alias_1 }
505
-
506
492
  declare const pupLogLevel: number;
507
493
  export { pupLogLevel }
508
494
  export { pupLogLevel as pupLogLevel_alias_1 }
@@ -569,6 +555,8 @@ declare const RenderSchema: z.ZodObject<{
569
555
  export { RenderSchema }
570
556
  export { RenderSchema as RenderSchema_alias_1 }
571
557
 
558
+ export declare function resizeDrawable(cdp: Debugger, size: Size): Promise<void>;
559
+
572
560
  declare interface RetryOptions<Args extends any[], Ret> {
573
561
  fn: (...args: Args) => Promise<Ret>;
574
562
  maxAttempts?: number;
@@ -580,7 +568,12 @@ export { RetryOptions as RetryOptions_alias_1 }
580
568
  /** Rewrite nuh_layer_id in a NAL unit (returns copy). */
581
569
  export declare function rewriteNalLayerId(nal: Buffer, layerId: number): Buffer;
582
570
 
583
- export declare function runElectronApp(size: Size, args: unknown[], ipcSocketPath: string): Promise<ProcessHandle>;
571
+ export declare function runElectronApp({ args, display }: RunElectronAppOptions): Promise<ProcessHandle>;
572
+
573
+ export declare interface RunElectronAppOptions {
574
+ args: unknown[];
575
+ display?: number;
576
+ }
584
577
 
585
578
  export declare function setInterceptor({ source, window, useInnerProxy }: NetworkOptions): void;
586
579
 
@@ -590,6 +583,8 @@ export declare function setupPupProtocol(): void;
590
583
 
591
584
  export declare function shoot(writer: IpcWriter, source: string, options: RenderOptions): Promise<IpcDonePayload>;
592
585
 
586
+ export declare function sizeEquals(a: Size, b: Size): boolean;
587
+
593
588
  declare function sleep(ms: number): Promise<void>;
594
589
  export { sleep }
595
590
  export { sleep as sleep_alias_1 }
@@ -597,15 +592,21 @@ export { sleep as sleep_alias_1 }
597
592
  /** Split Annex B bitstream into NAL units. */
598
593
  export declare function splitNalUnits(bitstream: Buffer): NalUnit[];
599
594
 
600
- export declare function startStego(cdp: Debugger): Promise<any>;
595
+ export declare function startElectronCrashReporter(): void;
596
+
597
+ export declare function startStego(cdp: Debugger): Promise<void>;
598
+
599
+ export declare function startXvfb(width: number, height: number): XvfbHandle;
601
600
 
602
601
  export declare const STEGO_TICK_CHANNEL = "stego-tick";
603
602
 
604
- export declare function stopStego(cdp: Debugger): Promise<any>;
603
+ export declare function stopStego(cdp: Debugger): Promise<void>;
605
604
 
606
- export declare const TICK_SYMBOL = "__pup_tick__";
605
+ export declare function swapBuffer(cdp: Debugger, expected: number): Promise<void>;
606
+
607
+ export declare function tick(frame: WebFrameMain | undefined, timestampMs: number): Promise<void>;
607
608
 
608
- export declare function tickStego(cdp: Debugger, ms: number): Promise<any>;
609
+ export declare const TICK_SYMBOL = "__pup_tick__";
609
610
 
610
611
  export declare interface UnifiedExtradataOptions {
611
612
  baseExtradata: Buffer;
@@ -707,4 +708,9 @@ export declare interface WindowOptions {
707
708
  tolerant?: boolean;
708
709
  }
709
710
 
711
+ export declare interface XvfbHandle {
712
+ display: number;
713
+ stop(): void;
714
+ }
715
+
710
716
  export { }