@napuketto/media 0.0.4 → 0.0.5

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/dist/index.cjs CHANGED
@@ -2809,7 +2809,7 @@ function parseMilliseconds(milliseconds) {
2809
2809
  throw new TypeError("Expected a finite number or bigint");
2810
2810
  }
2811
2811
  //#endregion
2812
- //#region ../../node_modules/.pnpm/pretty-ms@9.3.0/node_modules/pretty-ms/index.js
2812
+ //#region ../../node_modules/.pnpm/pretty-ms@9.3.1/node_modules/pretty-ms/index.js
2813
2813
  const isZero = (value) => value === 0 || value === 0n;
2814
2814
  const pluralize = (word, count) => count === 1 || count === 1n ? word : `${word}s`;
2815
2815
  const SECOND_ROUNDING_EPSILON = 1e-7;
@@ -2872,7 +2872,9 @@ function prettyMilliseconds(milliseconds, options) {
2872
2872
  } else {
2873
2873
  const millisecondsAndBelow = milliseconds + microseconds / 1e3 + nanoseconds / 1e6;
2874
2874
  const millisecondsDecimalDigits = typeof options.millisecondsDecimalDigits === "number" ? options.millisecondsDecimalDigits : 0;
2875
- const millisecondsString = millisecondsDecimalDigits ? millisecondsAndBelow.toFixed(millisecondsDecimalDigits) : millisecondsAndBelow >= 1 ? Math.round(millisecondsAndBelow) : Math.ceil(millisecondsAndBelow);
2875
+ const roundedMilliseconds = millisecondsAndBelow >= 1 ? Math.round(millisecondsAndBelow) : Math.ceil(millisecondsAndBelow);
2876
+ const maximumMilliseconds = 1e3 - 10 ** -millisecondsDecimalDigits;
2877
+ const millisecondsString = millisecondsDecimalDigits ? Math.min(millisecondsAndBelow, maximumMilliseconds).toFixed(millisecondsDecimalDigits) : Math.min(roundedMilliseconds, maximumMilliseconds);
2876
2878
  add(Number.parseFloat(millisecondsString), "millisecond", "ms", millisecondsString);
2877
2879
  }
2878
2880
  } else {
@@ -7528,7 +7530,7 @@ var require_ms = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7528
7530
  }
7529
7531
  }));
7530
7532
  //#endregion
7531
- //#region ../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/common.js
7533
+ //#region ../../node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/common.js
7532
7534
  var require_common = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7533
7535
  /**
7534
7536
  * This is the common logic for both the Node.js and web browser
@@ -7731,7 +7733,7 @@ var require_common = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7731
7733
  module.exports = setup;
7732
7734
  }));
7733
7735
  //#endregion
7734
- //#region ../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/browser.js
7736
+ //#region ../../node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/browser.js
7735
7737
  var require_browser = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7736
7738
  /**
7737
7739
  * This is the web browser implementation of `debug()`.
@@ -7937,19 +7939,21 @@ var require_has_flag = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7937
7939
  };
7938
7940
  }));
7939
7941
  //#endregion
7940
- //#region ../../node_modules/.pnpm/supports-color@7.2.0/node_modules/supports-color/index.js
7942
+ //#region ../../node_modules/.pnpm/supports-color@8.1.1/node_modules/supports-color/index.js
7941
7943
  var require_supports_color = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7942
7944
  const os = require("os");
7943
7945
  const tty$1 = require("tty");
7944
7946
  const hasFlag = require_has_flag();
7945
7947
  const { env } = process;
7946
- let forceColor;
7947
- if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) forceColor = 0;
7948
- else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) forceColor = 1;
7949
- if ("FORCE_COLOR" in env) {
7950
- if (env.FORCE_COLOR === "true") forceColor = 1;
7951
- else if (env.FORCE_COLOR === "false") forceColor = 0;
7952
- else forceColor = env.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env.FORCE_COLOR, 10), 3);
7948
+ let flagForceColor;
7949
+ if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) flagForceColor = 0;
7950
+ else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) flagForceColor = 1;
7951
+ function envForceColor() {
7952
+ if ("FORCE_COLOR" in env) {
7953
+ if (env.FORCE_COLOR === "true") return 1;
7954
+ if (env.FORCE_COLOR === "false") return 0;
7955
+ return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
7956
+ }
7953
7957
  }
7954
7958
  function translateLevel(level) {
7955
7959
  if (level === 0) return false;
@@ -7960,10 +7964,15 @@ var require_supports_color = /* @__PURE__ */ __commonJSMin(((exports, module) =>
7960
7964
  has16m: level >= 3
7961
7965
  };
7962
7966
  }
7963
- function supportsColor(haveStream, streamIsTTY) {
7967
+ function supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
7968
+ const noFlagForceColor = envForceColor();
7969
+ if (noFlagForceColor !== void 0) flagForceColor = noFlagForceColor;
7970
+ const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
7964
7971
  if (forceColor === 0) return 0;
7965
- if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) return 3;
7966
- if (hasFlag("color=256")) return 2;
7972
+ if (sniffFlags) {
7973
+ if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) return 3;
7974
+ if (hasFlag("color=256")) return 2;
7975
+ }
7967
7976
  if (haveStream && !streamIsTTY && forceColor === void 0) return 0;
7968
7977
  const min = forceColor || 0;
7969
7978
  if (env.TERM === "dumb") return min;
@@ -7979,14 +7988,15 @@ var require_supports_color = /* @__PURE__ */ __commonJSMin(((exports, module) =>
7979
7988
  "APPVEYOR",
7980
7989
  "GITLAB_CI",
7981
7990
  "GITHUB_ACTIONS",
7982
- "BUILDKITE"
7991
+ "BUILDKITE",
7992
+ "DRONE"
7983
7993
  ].some((sign) => sign in env) || env.CI_NAME === "codeship") return 1;
7984
7994
  return min;
7985
7995
  }
7986
7996
  if ("TEAMCITY_VERSION" in env) return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
7987
7997
  if (env.COLORTERM === "truecolor") return 3;
7988
7998
  if ("TERM_PROGRAM" in env) {
7989
- const version = parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
7999
+ const version = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
7990
8000
  switch (env.TERM_PROGRAM) {
7991
8001
  case "iTerm.app": return version >= 3 ? 3 : 2;
7992
8002
  case "Apple_Terminal": return 2;
@@ -7997,17 +8007,20 @@ var require_supports_color = /* @__PURE__ */ __commonJSMin(((exports, module) =>
7997
8007
  if ("COLORTERM" in env) return 1;
7998
8008
  return min;
7999
8009
  }
8000
- function getSupportLevel(stream) {
8001
- return translateLevel(supportsColor(stream, stream && stream.isTTY));
8010
+ function getSupportLevel(stream, options = {}) {
8011
+ return translateLevel(supportsColor(stream, {
8012
+ streamIsTTY: stream && stream.isTTY,
8013
+ ...options
8014
+ }));
8002
8015
  }
8003
8016
  module.exports = {
8004
8017
  supportsColor: getSupportLevel,
8005
- stdout: translateLevel(supportsColor(true, tty$1.isatty(1))),
8006
- stderr: translateLevel(supportsColor(true, tty$1.isatty(2)))
8018
+ stdout: getSupportLevel({ isTTY: tty$1.isatty(1) }),
8019
+ stderr: getSupportLevel({ isTTY: tty$1.isatty(2) })
8007
8020
  };
8008
8021
  }));
8009
8022
  //#endregion
8010
- //#region ../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/node.js
8023
+ //#region ../../node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/node.js
8011
8024
  var require_node = /* @__PURE__ */ __commonJSMin(((exports, module) => {
8012
8025
  /**
8013
8026
  * Module dependencies.
@@ -8579,7 +8592,7 @@ function getUintBE(view) {
8579
8592
  if (byteLength === 1) return view.getUint8(0);
8580
8593
  }
8581
8594
  //#endregion
8582
- //#region ../../node_modules/.pnpm/file-type@22.0.1/node_modules/file-type/source/tokens.js
8595
+ //#region ../../node_modules/.pnpm/file-type@22.0.2/node_modules/file-type/source/tokens.js
8583
8596
  function stringToBytes(string, encoding) {
8584
8597
  if (encoding === "utf-16le") {
8585
8598
  const bytes = [];
@@ -8623,7 +8636,7 @@ const uint32SyncSafeToken = {
8623
8636
  len: 4
8624
8637
  };
8625
8638
  //#endregion
8626
- //#region ../../node_modules/.pnpm/file-type@22.0.1/node_modules/file-type/source/supported.js
8639
+ //#region ../../node_modules/.pnpm/file-type@22.0.2/node_modules/file-type/source/supported.js
8627
8640
  const extensions = [
8628
8641
  "jpg",
8629
8642
  "png",
@@ -8990,7 +9003,7 @@ const mimeTypes = [
8990
9003
  "application/vnd.apple.pages"
8991
9004
  ];
8992
9005
  //#endregion
8993
- //#region ../../node_modules/.pnpm/file-type@22.0.1/node_modules/file-type/source/parser.js
9006
+ //#region ../../node_modules/.pnpm/file-type@22.0.2/node_modules/file-type/source/parser.js
8994
9007
  const maximumUntrustedSkipSizeInBytes = 16777216;
8995
9008
  var ParserHardLimitError = class extends Error {};
8996
9009
  function getSafeBound(value, maximum, reason) {
@@ -9026,7 +9039,7 @@ function hasExceededUnknownSizeScanBudget(tokenizer, startOffset, maximumBytes)
9026
9039
  return hasUnknownFileSize(tokenizer) && tokenizer.position - startOffset > maximumBytes;
9027
9040
  }
9028
9041
  //#endregion
9029
- //#region ../../node_modules/.pnpm/file-type@22.0.1/node_modules/file-type/source/detectors/zip.js
9042
+ //#region ../../node_modules/.pnpm/file-type@22.0.2/node_modules/file-type/source/detectors/zip.js
9030
9043
  const maximumZipEntrySizeInBytes = 1048576;
9031
9044
  const maximumZipEntryCount = 1024;
9032
9045
  const maximumZipBufferedReadSizeInBytes = 2 ** 31 - 1;
@@ -9061,11 +9074,13 @@ async function decompressDeflateRawWithLimit(data, { maximumLength = maximumZipE
9061
9074
  if (done) break;
9062
9075
  totalLength += value.length;
9063
9076
  if (totalLength > maximumLength) {
9064
- await reader.cancel();
9077
+ await reader.cancel().catch(() => {});
9065
9078
  throw new Error(`ZIP entry decompressed data exceeds ${maximumLength} bytes`);
9066
9079
  }
9067
9080
  chunks.push(value);
9068
9081
  }
9082
+ } catch (error) {
9083
+ if (error.code !== "ERR_TRAILING_JUNK_AFTER_STREAM_END") throw error;
9069
9084
  } finally {
9070
9085
  reader.releaseLock();
9071
9086
  }
@@ -9458,7 +9473,7 @@ async function detectZip(tokenizer) {
9458
9473
  };
9459
9474
  }
9460
9475
  //#endregion
9461
- //#region ../../node_modules/.pnpm/file-type@22.0.1/node_modules/file-type/source/detectors/ebml.js
9476
+ //#region ../../node_modules/.pnpm/file-type@22.0.2/node_modules/file-type/source/detectors/ebml.js
9462
9477
  const maximumEbmlDocumentTypeSizeInBytes = 64;
9463
9478
  const maximumEbmlElementPayloadSizeInBytes = 1048576;
9464
9479
  const maximumEbmlElementCount = 256;
@@ -9526,7 +9541,7 @@ async function detectEbml(tokenizer) {
9526
9541
  }
9527
9542
  }
9528
9543
  //#endregion
9529
- //#region ../../node_modules/.pnpm/file-type@22.0.1/node_modules/file-type/source/detectors/png.js
9544
+ //#region ../../node_modules/.pnpm/file-type@22.0.2/node_modules/file-type/source/detectors/png.js
9530
9545
  const maximumPngChunkCount = 512;
9531
9546
  const maximumPngStreamScanBudgetInBytes = 16777216;
9532
9547
  const maximumPngChunkSizeInBytes = 1048576;
@@ -9585,7 +9600,7 @@ async function detectPng(tokenizer) {
9585
9600
  return pngFileType;
9586
9601
  }
9587
9602
  //#endregion
9588
- //#region ../../node_modules/.pnpm/file-type@22.0.1/node_modules/file-type/source/detectors/asf.js
9603
+ //#region ../../node_modules/.pnpm/file-type@22.0.2/node_modules/file-type/source/detectors/asf.js
9589
9604
  const maximumAsfHeaderObjectCount = 512;
9590
9605
  const maximumAsfHeaderPayloadSizeInBytes = 1048576;
9591
9606
  async function detectAsf(tokenizer) {
@@ -9712,12 +9727,12 @@ async function detectAsf(tokenizer) {
9712
9727
  };
9713
9728
  }
9714
9729
  //#endregion
9715
- //#region ../../node_modules/.pnpm/file-type@22.0.1/node_modules/file-type/source/index.js
9730
+ //#region ../../node_modules/.pnpm/file-type@22.0.2/node_modules/file-type/source/index.js
9716
9731
  /**
9717
9732
  Primary entry point, Node.js specific entry point is index.js
9718
9733
  */
9719
9734
  const reasonableDetectionSizeInBytes = 4100;
9720
- const maximumMpegOffsetTolerance = 4098;
9735
+ const maximumMpegOffsetTolerance = 4096;
9721
9736
  const maximumNestedGzipDetectionSizeInBytes = maximumUntrustedSkipSizeInBytes;
9722
9737
  const maximumNestedGzipProbeDepth = 1;
9723
9738
  const unknownSizeGzipProbeTimeoutInMilliseconds = 100;
@@ -11310,10 +11325,10 @@ var FileTypeParser = class FileTypeParser {
11310
11325
  mime: "image/x-icon"
11311
11326
  };
11312
11327
  await tokenizer.peekBuffer(this.buffer, {
11313
- length: Math.min(2 + this.options.mpegOffsetTolerance, fileSize),
11328
+ length: Math.min(4 + this.options.mpegOffsetTolerance, fileSize),
11314
11329
  mayBeLess: true
11315
11330
  });
11316
- if (this.buffer.length >= 2 + this.options.mpegOffsetTolerance) for (let depth = 0; depth <= this.options.mpegOffsetTolerance; ++depth) {
11331
+ if (this.buffer.length >= 4 + this.options.mpegOffsetTolerance) for (let depth = 0; depth <= this.options.mpegOffsetTolerance; ++depth) {
11317
11332
  const type = this.scanMpeg(depth);
11318
11333
  if (type) return type;
11319
11334
  }
@@ -11399,19 +11414,23 @@ var FileTypeParser = class FileTypeParser {
11399
11414
  if (this.check([16], {
11400
11415
  offset: offset + 1,
11401
11416
  mask: [22]
11402
- })) {
11403
- if (this.check([8], {
11404
- offset: offset + 1,
11405
- mask: [8]
11406
- })) return {
11407
- ext: "aac",
11408
- mime: "audio/aac"
11409
- };
11410
- return {
11411
- ext: "aac",
11412
- mime: "audio/aac"
11413
- };
11414
- }
11417
+ })) return {
11418
+ ext: "aac",
11419
+ mime: "audio/aac"
11420
+ };
11421
+ if (this.check([255, 254], { offset })) return;
11422
+ if (this.check([8], {
11423
+ offset: offset + 1,
11424
+ mask: [24]
11425
+ })) return;
11426
+ if (this.check([240], {
11427
+ offset: offset + 2,
11428
+ mask: [240]
11429
+ })) return;
11430
+ if (this.check([12], {
11431
+ offset: offset + 2,
11432
+ mask: [12]
11433
+ })) return;
11415
11434
  if (this.check([2], {
11416
11435
  offset: offset + 1,
11417
11436
  mask: [6]
@@ -11475,6 +11494,7 @@ async function detectFileType(input) {
11475
11494
  * ffmpeg 由 execa 以子进程方式调用(非 node 内置),依赖系统 PATH 中的 ffmpeg。
11476
11495
  * - `transcodeVideo`:转码 / 缩放 / 帧率
11477
11496
  * - `getVideoInfo`:解析 ffprobe 输出取宽高与时长
11497
+ * - `extractVideoFrame`:抽首帧作缩略图(QQ 视频消息发送需要)
11478
11498
  */
11479
11499
  const MS_PER_SECOND = 1e3;
11480
11500
  /** 替换扩展名(保持目录,父目录由调用方保证存在)。 */
@@ -11549,6 +11569,37 @@ async function getVideoInfo(input) {
11549
11569
  durationMs: Math.round(Number(durationStr) * MS_PER_SECOND)
11550
11570
  };
11551
11571
  }
11572
+ /**
11573
+ * 抽视频首帧为 PNG 缩略图(QQ 视频消息发送契约:thumbPath 指向真实图片文件)。
11574
+ *
11575
+ * 固定 `-ss 0` 取首帧:QQ 缩略图只需要一张可解码的封面,首帧最稳定
11576
+ * (部分视频首帧为黑屏时可改 1s,此处不引入额外配置)。转码失败 / ffmpeg
11577
+ * 缺失 / 输出未生成均抛 MediaError,由调用方决定降级策略。
11578
+ */
11579
+ async function extractVideoFrame(input, outputPath) {
11580
+ const args = [
11581
+ "-y",
11582
+ "-ss",
11583
+ "0",
11584
+ "-i",
11585
+ input,
11586
+ "-frames:v",
11587
+ "1",
11588
+ "-q:v",
11589
+ "3",
11590
+ "-f",
11591
+ "image2",
11592
+ outputPath
11593
+ ];
11594
+ let exitCode;
11595
+ try {
11596
+ exitCode = (await execa("ffmpeg", args, { reject: false })).exitCode;
11597
+ } catch (err) {
11598
+ throw new MediaError(`ffmpeg 不可用或抽帧失败: ${input}`, { cause: err });
11599
+ }
11600
+ if (exitCode !== 0 || !(0, node_fs.existsSync)(outputPath)) throw new MediaError(`ffmpeg 抽帧失败: ${input}(exit ${exitCode ?? "?"})`);
11601
+ return outputPath;
11602
+ }
11552
11603
  //#endregion
11553
11604
  exports.MediaError = MediaError;
11554
11605
  exports.SILK_SAMPLE_RATE = SILK_SAMPLE_RATE;
@@ -11557,6 +11608,7 @@ exports.decodeSilkToWav = decodeSilkToWav;
11557
11608
  exports.detectFileType = detectFileType;
11558
11609
  exports.downloadUrl = downloadUrl;
11559
11610
  exports.encodePcmToSilk = encodePcmToSilk;
11611
+ exports.extractVideoFrame = extractVideoFrame;
11560
11612
  exports.getImageSize = getImageSize;
11561
11613
  exports.getSilkInfo = getSilkInfo;
11562
11614
  exports.getVideoInfo = getVideoInfo;
package/dist/index.d.cts CHANGED
@@ -118,6 +118,14 @@ declare function detectFileType(input: string): Promise<FileTypeResult>;
118
118
  declare function transcodeVideo(input: string, opts?: TranscodeOptions): Promise<string>;
119
119
  /** 读取视频宽高与时长(ffprobe JSON 输出解析)。 */
120
120
  declare function getVideoInfo(input: string): Promise<VideoInfo>;
121
+ /**
122
+ * 抽视频首帧为 PNG 缩略图(QQ 视频消息发送契约:thumbPath 指向真实图片文件)。
123
+ *
124
+ * 固定 `-ss 0` 取首帧:QQ 缩略图只需要一张可解码的封面,首帧最稳定
125
+ * (部分视频首帧为黑屏时可改 1s,此处不引入额外配置)。转码失败 / ffmpeg
126
+ * 缺失 / 输出未生成均抛 MediaError,由调用方决定降级策略。
127
+ */
128
+ declare function extractVideoFrame(input: string, outputPath: string): Promise<string>;
121
129
  //#endregion
122
- export { type AudioInfo, type DecodeSilkToWavOptions, type DecodedAudio, type DecodedWav, type DownloadUrlOptions, type FileTypeResult, type ImageSize, MediaError, SILK_SAMPLE_RATE, type TranscodeOptions, type VideoInfo, decodeSilkToPcm, decodeSilkToWav, detectFileType, downloadUrl, encodePcmToSilk, getImageSize, getSilkInfo, getVideoInfo, inferExtension, transcodeVideo };
130
+ export { type AudioInfo, type DecodeSilkToWavOptions, type DecodedAudio, type DecodedWav, type DownloadUrlOptions, type FileTypeResult, type ImageSize, MediaError, SILK_SAMPLE_RATE, type TranscodeOptions, type VideoInfo, decodeSilkToPcm, decodeSilkToWav, detectFileType, downloadUrl, encodePcmToSilk, extractVideoFrame, getImageSize, getSilkInfo, getVideoInfo, inferExtension, transcodeVideo };
123
131
  //# sourceMappingURL=index.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../src/types.ts","../src/audio.ts","../src/downloader.ts","../src/image.ts","../src/video.ts"],"mappings":";;;;;;;UAOiB;EACb;EACA;;;UAIa;;EAEb;;EAEA;;;UAIa;;EAEb;;EAEA;;;UAIa;EACb;EACA;;EAEA;;;UAIa;EACb;EACA;EACA;;;UAIa;;EAEb;;EAEA;;;cAIS,mBAAmB;EAC5B,YAAY,iBAAiB,UAAU;;;;;cChC9B;;iBAmBS,gBAClB,eACA,sBACD,QAAQ;;UAYM;;EAEb;;EAEA;;;UAIa;EACb;EACA;;;;;;;iBAQkB,gBAClB,eACA,UAAS,yBACV,QAAQ;;;;;;;;;iBAqDW,gBAAgB,eAAe,sBAAiB;;iBAuEhD,YAClB,eACA,sBACD,QAAQ;;;;;;;;;;;UClMM;;EAEb;;EAEA;;;;;;;iBAiBkB,YAClB,aACA,cACA,UAAS,qBACV;;iBA6Ca,eAAe,4BAA4B;;;;iBClErC,aAAa,gBAAgB,QAAQ;;iBAOrC,eAAe,gBAAgB,QAAQ;;;;iBCyBvC,eAAe,eAAe,OAAM,mBAAwB;;iBA+B5D,aAAa,gBAAgB,QAAQ"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/types.ts","../src/audio.ts","../src/downloader.ts","../src/image.ts","../src/video.ts"],"mappings":";;;;;;;UAOiB;EACb;EACA;;;UAIa;;EAEb;;EAEA;;;UAIa;;EAEb;;EAEA;;;UAIa;EACb;EACA;;EAEA;;;UAIa;EACb;EACA;EACA;;;UAIa;;EAEb;;EAEA;;;cAIS,mBAAmB;EAC5B,YAAY,iBAAiB,UAAU;;;;;cChC9B;;iBAmBS,gBAClB,eACA,sBACD,QAAQ;;UAYM;;EAEb;;EAEA;;;UAIa;EACb;EACA;;;;;;;iBAQkB,gBAClB,eACA,UAAS,yBACV,QAAQ;;;;;;;;;iBAqDW,gBAAgB,eAAe,sBAAiB;;iBAuEhD,YAClB,eACA,sBACD,QAAQ;;;;;;;;;;;UClMM;;EAEb;;EAEA;;;;;;;iBAiBkB,YAClB,aACA,cACA,UAAS,qBACV;;iBA6Ca,eAAe,4BAA4B;;;;iBClErC,aAAa,gBAAgB,QAAQ;;iBAOrC,eAAe,gBAAgB,QAAQ;;;;iBC0BvC,eAAe,eAAe,OAAM,mBAAwB;;iBA+B5D,aAAa,gBAAgB,QAAQ;;;;;;;;iBAoCrC,kBAAkB,eAAe,qBAAqB"}
package/dist/index.d.mts CHANGED
@@ -118,6 +118,14 @@ declare function detectFileType(input: string): Promise<FileTypeResult>;
118
118
  declare function transcodeVideo(input: string, opts?: TranscodeOptions): Promise<string>;
119
119
  /** 读取视频宽高与时长(ffprobe JSON 输出解析)。 */
120
120
  declare function getVideoInfo(input: string): Promise<VideoInfo>;
121
+ /**
122
+ * 抽视频首帧为 PNG 缩略图(QQ 视频消息发送契约:thumbPath 指向真实图片文件)。
123
+ *
124
+ * 固定 `-ss 0` 取首帧:QQ 缩略图只需要一张可解码的封面,首帧最稳定
125
+ * (部分视频首帧为黑屏时可改 1s,此处不引入额外配置)。转码失败 / ffmpeg
126
+ * 缺失 / 输出未生成均抛 MediaError,由调用方决定降级策略。
127
+ */
128
+ declare function extractVideoFrame(input: string, outputPath: string): Promise<string>;
121
129
  //#endregion
122
- export { type AudioInfo, type DecodeSilkToWavOptions, type DecodedAudio, type DecodedWav, type DownloadUrlOptions, type FileTypeResult, type ImageSize, MediaError, SILK_SAMPLE_RATE, type TranscodeOptions, type VideoInfo, decodeSilkToPcm, decodeSilkToWav, detectFileType, downloadUrl, encodePcmToSilk, getImageSize, getSilkInfo, getVideoInfo, inferExtension, transcodeVideo };
130
+ export { type AudioInfo, type DecodeSilkToWavOptions, type DecodedAudio, type DecodedWav, type DownloadUrlOptions, type FileTypeResult, type ImageSize, MediaError, SILK_SAMPLE_RATE, type TranscodeOptions, type VideoInfo, decodeSilkToPcm, decodeSilkToWav, detectFileType, downloadUrl, encodePcmToSilk, extractVideoFrame, getImageSize, getSilkInfo, getVideoInfo, inferExtension, transcodeVideo };
123
131
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/types.ts","../src/audio.ts","../src/downloader.ts","../src/image.ts","../src/video.ts"],"mappings":";;;;;;;UAOiB;EACb;EACA;;;UAIa;;EAEb;;EAEA;;;UAIa;;EAEb;;EAEA;;;UAIa;EACb;EACA;;EAEA;;;UAIa;EACb;EACA;EACA;;;UAIa;;EAEb;;EAEA;;;cAIS,mBAAmB;EAC5B,YAAY,iBAAiB,UAAU;;;;;cChC9B;;iBAmBS,gBAClB,eACA,sBACD,QAAQ;;UAYM;;EAEb;;EAEA;;;UAIa;EACb;EACA;;;;;;;iBAQkB,gBAClB,eACA,UAAS,yBACV,QAAQ;;;;;;;;;iBAqDW,gBAAgB,eAAe,sBAAiB;;iBAuEhD,YAClB,eACA,sBACD,QAAQ;;;;;;;;;;;UClMM;;EAEb;;EAEA;;;;;;;iBAiBkB,YAClB,aACA,cACA,UAAS,qBACV;;iBA6Ca,eAAe,4BAA4B;;;;iBClErC,aAAa,gBAAgB,QAAQ;;iBAOrC,eAAe,gBAAgB,QAAQ;;;;iBCyBvC,eAAe,eAAe,OAAM,mBAAwB;;iBA+B5D,aAAa,gBAAgB,QAAQ"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/types.ts","../src/audio.ts","../src/downloader.ts","../src/image.ts","../src/video.ts"],"mappings":";;;;;;;UAOiB;EACb;EACA;;;UAIa;;EAEb;;EAEA;;;UAIa;;EAEb;;EAEA;;;UAIa;EACb;EACA;;EAEA;;;UAIa;EACb;EACA;EACA;;;UAIa;;EAEb;;EAEA;;;cAIS,mBAAmB;EAC5B,YAAY,iBAAiB,UAAU;;;;;cChC9B;;iBAmBS,gBAClB,eACA,sBACD,QAAQ;;UAYM;;EAEb;;EAEA;;;UAIa;EACb;EACA;;;;;;;iBAQkB,gBAClB,eACA,UAAS,yBACV,QAAQ;;;;;;;;;iBAqDW,gBAAgB,eAAe,sBAAiB;;iBAuEhD,YAClB,eACA,sBACD,QAAQ;;;;;;;;;;;UClMM;;EAEb;;EAEA;;;;;;;iBAiBkB,YAClB,aACA,cACA,UAAS,qBACV;;iBA6Ca,eAAe,4BAA4B;;;;iBClErC,aAAa,gBAAgB,QAAQ;;iBAOrC,eAAe,gBAAgB,QAAQ;;;;iBC0BvC,eAAe,eAAe,OAAM,mBAAwB;;iBA+B5D,aAAa,gBAAgB,QAAQ;;;;;;;;iBAoCrC,kBAAkB,eAAe,qBAAqB"}