qxan-decoder-sdk
v0.1.2
Published
Client-side decoding library for AI-generated images and videos, powered by Qxan AI.
Maintainers
Readme
qxan-decoder-sdk
A powerful, client-side library for decoding AI-generated steganographic content from multiple formats (TT-tools, SS_tools, etc.). Supports images, videos, and password-protected content.
支持的格式
| 解码器 | 格式名称 | 密码支持 | LSB位深 | 特性 |
|--------|----------|----------|---------|------|
| QxanDecoder | Qxan AI 原生格式 | ❌ | 1位 | 视频隐藏在PNG中 |
| TTDecoderV1 | TT-tools V1 | ❌ | 1位 | 跳过上下20%,抗水印 |
| TTDecoderV2 | TT-tools V2 | ❌ | 8位 | CRC16校验,跳过顶部6% |
| TTDecoderPW | TT-tools PW | ✅ | 1位 | 密码保护,跳过顶部5% |
| SSDecoder | SS_tools | ✅ | 2/6/8位 | 自动位深检测,区域屏蔽 |
安装
npm install qxan-decoder-sdk
# 或
pnpm add qxan-decoder-sdk快速开始
1. QxanDecoder (原生格式)
import { QxanDecoder } from "qxan-decoder-sdk";
// 解码文件
const result = await QxanDecoder.decode(fileInput.files[0], {
expect: "video", // 或 'image' 提取关键帧
onProgress: (msg) => console.log(msg),
});
if (result.type === "video") {
videoElement.src = result.videoUrl;
console.log("元数据:", result.metadata);
}2. TTDecoderV1 (TT-tools V1)
import { TTDecoderV1 } from "qxan-decoder-sdk";
const result = await TTDecoderV1.decode(imageFile, {
expect: "video",
onProgress: (msg) => console.log("[TT-V1]", msg),
});3. TTDecoderV2 (TT-tools V2)
import { TTDecoderV2 } from "qxan-decoder-sdk";
const result = await TTDecoderV2.decode(imageFile, {
expect: "image", // 提取关键帧
maxFrames: 6,
onProgress: (msg) => console.log("[TT-V2]", msg),
});4. TTDecoderPW (TT-tools 密码版)
import { TTDecoderPW } from "qxan-decoder-sdk";
const result = await TTDecoderPW.decode(
imageFile,
"your-password", // 密码参数
{
expect: "video",
onProgress: (msg) => console.log("[TT-PW]", msg),
}
);5. SSDecoder (SS_tools)
import { SSDecoder } from "qxan-decoder-sdk";
const result = await SSDecoder.decode(
imageFile,
"optional-password", // 可选密码
{
expect: "image", // 对于 binpng 格式可提取帧
maxFrames: 8,
onProgress: (msg) => console.log("[SS]", msg),
}
);通用选项
所有解码器都支持以下选项:
interface DecodeOptions {
/**
* 期望输出格式
* - 'video': 返回原始视频文件
* - 'image': 提取视频的关键帧
*/
expect: "image" | "video";
/**
* 当 expect='image' 时,最大提取帧数
* 默认: 4
*/
maxFrames?: number;
/**
* 进度回调函数
*/
onProgress?: (msg: string) => void;
}返回结果
interface DecoderResult {
/** 内容类型 */
type: "video" | "image";
/** 解码后的视频 Blob */
videoBlob: Blob;
/** 视频 URL (可用于播放) */
videoUrl: string;
/** 提取的帧 (仅当 expect='image' 时) */
frames?: string[]; // Blob URLs 数组
/** 视频元数据 */
metadata?: {
duration: number; // 秒
width: number;
height: number;
estimatedFrames: number; // 基于 16 FPS 估算
};
}浏览器要求
- 所有解码器: 需要现代浏览器支持
Canvas和ImageAPI - QxanDecoder: 需要
SharedArrayBuffer支持 FFmpeg WASMCross-Origin-Opener-Policy: same-origin Cross-Origin-Embedder-Policy: require-corp
构建 & 发布
本地开发
# 安装依赖
pnpm install
# 开发模式 (监听文件变化)
pnpm dev
# 生产构建
pnpm build发布到 npm
登录 npm (首次需要):
npm login # 输入用户名、密码、邮箱检查版本:
# 查看当前版本 npm view qxan-decoder-sdk version # 查看本地 package.json 版本 cat package.json | grep version构建 SDK:
pnpm build # 检查 dist/ 目录是否生成正确 ls dist/发布:
# 发布公开包 npm publish # 或发布测试版本 npm publish --tag beta验证发布:
# 安装刚发布的版本 mkdir test-project cd test-project npm init -y npm install [email protected] # 测试导入 node -e "console.log(require('qxan-decoder-sdk'))"
许可证
MIT
