@file-type/av

中文文档
0.3.0发布于 2026/10/09MITTypeScriptES Module近 30 天下载 1.4万

file-type plugin for improved audio / video type detection

原始使用文档
文档目录9 节
  1. Installation
  2. Usage
  3. Supported Media Formats
  4. Matroska
  5. MP4
  6. Ogg
  7. WebM
  8. ASF / Windows Media
  9. License

NPM version Node.js CI npm downloads

@file-type/av

A plugin for file-type that detects audio and video file formats. This plugin helps differentiate between audio and video file types more precisely.

Installation

Requires Node.js 22 or newer.

npm install @file-type/av

Usage

Here’s how to use this plugin with file-type to detect audio/video formats:

import { fileTypeFromFile } from 'file-type';
import { detectAv } from '@file-type/av';

const fileType = await fileTypeFromFile('example.mka', {
  customDetectors: [detectAv]
});

console.log(JSON.stringify(fileType, null, 2));

Supported Media Formats

Matroska

  • audio/matroska – .mka
  • video/matroska – .mkv

MP4

  • audio/mp4 – .m4a
  • video/mp4 – .mp4

Ogg

  • audio/ogg; codecs=opus – .opus (Opus)
  • audio/ogg; codecs=speex – .spx (Speex)
  • audio/ogg; codecs=vorbis – .ogg (Vorbis)
  • video/ogg – .ogv (Theora)

WebM

  • audio/webm – .webm
  • video/webm – .webm

ASF / Windows Media

The plugin inspects all tracks, giving video precedence over audio. Windows Media codecs use .wma or .wmv; other codecs retain .asf.

  • audio/x-ms-asf – .wma
  • video/x-ms-asf – .wmv
  • audio/x-ms-asf – .asf (other audio codecs)
  • video/x-ms-asf – .asf (other video codecs)
  • application/vnd.ms-asf – .asf (no audio or video tracks)

License

Licensed under the MIT License. You are free to use, modify, and distribute this project as needed.

版本与发布记录

@file-type/av 共发布 3 个版本,首次发布于 2025/06/30;过去 12 个月发布了 1 个版本。

版本发布日期距今
0.3.0latest2026/10/091 个月前
0.2.02025/07/151.3 年前
0.1.02025/06/301.4 年前

关于 @file-type/av 的常见问题

@file-type/av 是什么?

file-type plugin for improved audio / video type detection

如何安装 @file-type/av?

在项目目录运行 npm install @file-type/av,或使用 pnpm add / yarn add / bun add。

@file-type/av 支持 TypeScript 吗?

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

@file-type/av 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@file-type/av 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@file-type/av 可以商用吗?

@file-type/av 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@file-type/av 的下载量有多少?

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

@file-type/av 还在维护吗?

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