@face-auth/face-id-video

中文文档
0.0.3发布于 2026/03/13SEE LICENSE IN LICENSETypeScriptESM + CJS零依赖近 30 天下载 2187

Utility library for capturing photos from webcam video streams in the browser. Handles camera selection, image formatting, and output for face authentication APIs.

原始使用文档
文档目录16 节
  1. Installation
  2. License
  3. Public API
  4. Class
  5. Exported types
  6. FaceVideo
  7. Methods
  8. Camera selection
  9. Capture output
  10. Camera started event
  11. Runtime contracts
  12. CameraOptions
  13. CaptureOptions
  14. CaptureResult
  15. Camera errors
  16. Notes

@face-auth/face-id-video

Browser-only webcam utilities for starting video streams and capturing still images. Current package version: 0.0.3.

Installation

npm install @face-auth/face-id-video

License

Proprietary runtime-only license. You may execute unmodified copies of the package, but modification, redistribution, sublicensing, and other reuse are not permitted. See LICENSE.

Public API

Import from the package root only. Deep imports into dist/ or dist/src/ are not part of the public contract.

Class

  • FaceVideo

Exported types

  • CameraError
  • CameraOptions
  • CaptureOptions
  • CaptureResult
  • FaceVideoElement
  • OvalDimensions

FaceVideo

Creates a camera/capture manager over an HTMLVideoElement.

import { FaceVideo } from "@face-auth/face-id-video";

const videoElement = document.getElementById("videoRef") as HTMLVideoElement;
const faceVideo = new FaceVideo(videoElement);

Methods

  • getDevices(): Promise<MediaDeviceInfo[]>
  • start(options?: CameraOptions, deviceId?: string): Promise<void>
  • capture(options: CaptureOptions): Promise<CaptureResult>
  • stop(): void
  • onCameraStarted(callback): void
  • offCameraStarted(callback): void

Camera selection

You can ask the browser for available video inputs:

const devices = await faceVideo.getDevices();

devices.forEach((device) => {
  console.log(device.deviceId, device.label);
});

To start the stream, either provide preferredFacingMode or pass a specific deviceId as the second argument.

await faceVideo.start({
  preferredFacingMode: "user",
  idealResolution: { width: 1280, height: 720 }
});
const devices = await faceVideo.getDevices();
const selectedDeviceId = devices[0]?.deviceId;

await faceVideo.start(
  {
    preferredFacingMode: "environment",
    idealResolution: { width: 1280, height: 720 }
  },
  selectedDeviceId
);

Capture output

capture() returns a CaptureResult with a blob and the resolved imageType.

const result = await faceVideo.capture({
  imageType: "image/jpeg"
});

console.log(result.blob);
console.log(result.imageType);

If imageType is omitted, the package uses image/png by default.

Camera started event

const handleCameraStarted = () => {
  console.log("Camera is ready");
};

faceVideo.onCameraStarted(handleCameraStarted);

await faceVideo.start({
  preferredFacingMode: "user"
});

faceVideo.offCameraStarted(handleCameraStarted);

Runtime contracts

CameraOptions

interface CameraOptions {
  preferredFacingMode?: "user" | "environment";
  idealResolution?: { width: number; height: number };
}

CaptureOptions

interface CaptureOptions {
  imageType?: string;
}

CaptureResult

interface CaptureResult {
  blob: Blob;
  imageType: string;
}

Camera errors

When start() fails, the thrown error may include one of these code values:

  • PERMISSION_DENIED
  • NO_DEVICES
  • OVERCONSTRAINED
  • UNKNOWN

Notes

  • capture() must be called after start().
  • The package currently returns captured images as Blob. It does not return Base64 directly.
  • The target environment is the browser.

版本与发布记录

@face-auth/face-id-video 共发布 3 个版本,首次发布于 2025/08/02;过去 12 个月发布了 1 个版本。

版本发布日期距今
0.0.3latest2026/03/138 个月前
0.0.22025/08/021.3 年前
0.0.12025/08/021.3 年前

关于 @face-auth/face-id-video 的常见问题

@face-auth/face-id-video 是什么?

Utility library for capturing photos from webcam video streams in the browser. Handles camera selection, image formatting, and output for face authentication APIs.

如何安装 @face-auth/face-id-video?

在项目目录运行 npm install @face-auth/face-id-video,或使用 pnpm add / yarn add / bun add。

@face-auth/face-id-video 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@face-auth/face-id-video 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@face-auth/face-id-video 可以商用吗?

@face-auth/face-id-video 使用 SEE LICENSE IN LICENSE 许可。许可条款写在包内的独立文件中,请阅读该文件确认可否商用。以上为概括,不构成法律意见,请以许可原文为准。

@face-auth/face-id-video 的下载量有多少?

根据 npm 官方下载统计,@face-auth/face-id-video 在 2026/10/14 – 2026/11/12 这 30 天内被下载 2,187 次,日均约 73 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@face-auth/face-id-video 还在维护吗?

最新版本 0.0.3 发布于 2026/03/13(8 个月前);至今共发布 3 个版本,其中过去 12 个月发布了 1 个;首次发布于 2025/08/02。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。