@napuketto/media 0.0.6 → 0.1.0
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.d.mts +14 -24
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +188 -11428
- package/dist/index.mjs.map +1 -1
- package/package.json +16 -16
- package/dist/index.cjs +0 -11616
- package/dist/index.d.cts +0 -131
- package/dist/index.d.cts.map +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/types.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* @napuketto/media 统一返回结构(ADR-011)
|
|
4
3
|
*
|
|
@@ -44,15 +43,13 @@ interface DecodedAudio {
|
|
|
44
43
|
durationMs: number;
|
|
45
44
|
}
|
|
46
45
|
/** 无法识别的文件类型(file-type 返回 undefined 时)。 */
|
|
47
|
-
declare class MediaError extends Error {
|
|
46
|
+
export declare class MediaError extends Error {
|
|
48
47
|
constructor(message: string, options?: ErrorOptions);
|
|
49
48
|
}
|
|
50
|
-
//#endregion
|
|
51
|
-
//#region src/audio.d.ts
|
|
52
49
|
/** SILK 默认采样率(Hz)。 */
|
|
53
|
-
declare const SILK_SAMPLE_RATE = 24000;
|
|
50
|
+
export declare const SILK_SAMPLE_RATE = 24000;
|
|
54
51
|
/** 解码 SILK 音频为 PCM(pcm_s16le)。 */
|
|
55
|
-
declare function decodeSilkToPcm(input: string, sampleRate?: number): Promise<DecodedAudio>;
|
|
52
|
+
export declare function decodeSilkToPcm(input: string, sampleRate?: number): Promise<DecodedAudio>;
|
|
56
53
|
/** 解码 SILK → WAV 输出选项。 */
|
|
57
54
|
interface DecodeSilkToWavOptions {
|
|
58
55
|
/** 采样率(缺省 24000,QQ 语音协议值)。 */
|
|
@@ -70,7 +67,7 @@ interface DecodedWav {
|
|
|
70
67
|
* 收方向语音接线用(koishi h.audio / 外部客户端):QQ 语音是 silk v3,
|
|
71
68
|
* 多数播放器无法直接解码,落 WAV 后以本地路径消费。
|
|
72
69
|
*/
|
|
73
|
-
declare function decodeSilkToWav(input: string, options?: DecodeSilkToWavOptions): Promise<DecodedWav>;
|
|
70
|
+
export declare function decodeSilkToWav(input: string, options?: DecodeSilkToWavOptions): Promise<DecodedWav>;
|
|
74
71
|
/**
|
|
75
72
|
* 编码任意音频为 SILK 文件(返回输出路径,输出紧随输入文件)。
|
|
76
73
|
*
|
|
@@ -79,11 +76,9 @@ declare function decodeSilkToWav(input: string, options?: DecodeSilkToWavOptions
|
|
|
79
76
|
* - 其余(立体声/浮点/非 16-bit WAV、mp3/ogg/amr/flac 等)→ ffmpeg 归一化为
|
|
80
77
|
* 24000Hz 单声道 pcm_s16le → silk-wasm 编码
|
|
81
78
|
*/
|
|
82
|
-
declare function encodePcmToSilk(input: string, sampleRate?: number): Promise<string>;
|
|
79
|
+
export declare function encodePcmToSilk(input: string, sampleRate?: number): Promise<string>;
|
|
83
80
|
/** 获取 SILK 音频信息(时长 / 采样率)。 */
|
|
84
|
-
declare function getSilkInfo(input: string, sampleRate?: number): Promise<AudioInfo>;
|
|
85
|
-
//#endregion
|
|
86
|
-
//#region src/downloader.d.ts
|
|
81
|
+
export declare function getSilkInfo(input: string, sampleRate?: number): Promise<AudioInfo>;
|
|
87
82
|
/**
|
|
88
83
|
* downloader.ts:HTTP(S) 媒体下载(2026-09-08 T5)
|
|
89
84
|
*
|
|
@@ -103,21 +98,17 @@ interface DownloadUrlOptions {
|
|
|
103
98
|
* 失败抛错(非 2xx / 超限 / 超时 / 空 body / IO 错误),不产生半成品语义
|
|
104
99
|
* (失败时目标文件可能残留,调用方负责清理目录)。
|
|
105
100
|
*/
|
|
106
|
-
declare function downloadUrl(url: string, dest: string, options?: DownloadUrlOptions): Promise<number>;
|
|
101
|
+
export declare function downloadUrl(url: string, dest: string, options?: DownloadUrlOptions): Promise<number>;
|
|
107
102
|
/** 从 Content-Type / URL 路径推断扩展名(缺省 .bin;下载命名用)。 */
|
|
108
|
-
declare function inferExtension(contentType: string | null, url: string): string;
|
|
109
|
-
//#endregion
|
|
110
|
-
//#region src/image.d.ts
|
|
103
|
+
export declare function inferExtension(contentType: string | null, url: string): string;
|
|
111
104
|
/** 读取图片尺寸(image-size 同步 API,内部读文件 + 计算)。 */
|
|
112
|
-
declare function getImageSize(input: string): Promise<ImageSize>;
|
|
105
|
+
export declare function getImageSize(input: string): Promise<ImageSize>;
|
|
113
106
|
/** 检测文件类型(魔数识别,返回 undefined 时抛 MediaError)。 */
|
|
114
|
-
declare function detectFileType(input: string): Promise<FileTypeResult>;
|
|
115
|
-
//#endregion
|
|
116
|
-
//#region src/video.d.ts
|
|
107
|
+
export declare function detectFileType(input: string): Promise<FileTypeResult>;
|
|
117
108
|
/** 转码:按选项输出到替换扩展名后的路径(.mp4)。ffmpeg 缺失/失败抛 MediaError。 */
|
|
118
|
-
declare function transcodeVideo(input: string, opts?: TranscodeOptions): Promise<string>;
|
|
109
|
+
export declare function transcodeVideo(input: string, opts?: TranscodeOptions): Promise<string>;
|
|
119
110
|
/** 读取视频宽高与时长(ffprobe JSON 输出解析)。 */
|
|
120
|
-
declare function getVideoInfo(input: string): Promise<VideoInfo>;
|
|
111
|
+
export declare function getVideoInfo(input: string): Promise<VideoInfo>;
|
|
121
112
|
/**
|
|
122
113
|
* 抽视频首帧为 PNG 缩略图(QQ 视频消息发送契约:thumbPath 指向真实图片文件)。
|
|
123
114
|
*
|
|
@@ -125,7 +116,6 @@ declare function getVideoInfo(input: string): Promise<VideoInfo>;
|
|
|
125
116
|
* (部分视频首帧为黑屏时可改 1s,此处不引入额外配置)。转码失败 / ffmpeg
|
|
126
117
|
* 缺失 / 输出未生成均抛 MediaError,由调用方决定降级策略。
|
|
127
118
|
*/
|
|
128
|
-
declare function extractVideoFrame(input: string, outputPath: string): Promise<string>;
|
|
129
|
-
|
|
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 };
|
|
119
|
+
export declare function extractVideoFrame(input: string, outputPath: string): Promise<string>;
|
|
120
|
+
export type { AudioInfo, DecodeSilkToWavOptions, DecodedAudio, DecodedWav, DownloadUrlOptions, FileTypeResult, ImageSize, TranscodeOptions, VideoInfo };
|
|
131
121
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -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":"
|
|
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;;;qBAIS,mBAAmB;EAC5B,YAAY,iBAAiB,UAAU;;;qBChC9B;;wBAmBS,gBAClB,eACA,sBACD,QAAQ;;UAYM;;EAEb;;EAEA;;;UAIa;EACb;EACA;;;;;;;wBAQkB,gBAClB,eACA,UAAS,yBACV,QAAQ;;;;;;;;;wBAqDW,gBAAgB,eAAe,sBAAiB;;wBAuEhD,YAClB,eACA,sBACD,QAAQ;;;;;;;;;UClMM;;EAEb;;EAEA;;;;;;;wBAiBkB,YAClB,aACA,cACA,UAAS,qBACV;;wBA6Ca,eAAe,4BAA4B;;wBClErC,aAAa,gBAAgB,QAAQ;;wBAOrC,eAAe,gBAAgB,QAAQ;;wBC0BvC,eAAe,eAAe,OAAM,mBAAwB;;wBA+B5D,aAAa,gBAAgB,QAAQ;;;;;;;;wBAoCrC,kBAAkB,eAAe,qBAAqB"}
|