npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

videoformat

v1.0.0

Published

视频格式处理工具

Readme

videoformat 视频格式处理工具

该插件是为了解决视频上传前获取视频基础数据及编码格式,从而判断是否需要进一步处理(如转码等)


1. 安装
  npm i videoformat
2. 使用 [ 获取视频基础信息 ]
  import videoFormat from 'videoformat'
  // 异步模式获取视频文件信息
  const info = videoFormat.getFormatsSync(file) 
   // 同步Promise获取视频文件信息
   videoFormat.getFormatsSync(file).then((res)=>{
      const info = res;
   })
  
// 返回数据
{
  audio:{ // 音频
    bitrate: 115752.538071066, // 比特率
    codec: "mp4a", //音频编码格式 
    created: Tue May 11 2010 18:32:06 GMT+0800 (中国标准时间) , // 创建时间
    size: 182426  // 音频大小
  },
  video:{ // 视频
    bitrate: 80637.48810656517, // 视频文件比特率
    codec: "avc1", // 视频文件编码格式
    created: Tue May 11 2010 18:32:06 GMT+0800 (中国标准时间), // 创建时间
    height: 240, // 视频高度
    size: 127125, // 视频大小
    width: 320, // 视频宽度
  }
}
3. 使用 [ 检测视频文件是否WEB浏览器可用 ]
  import videoFormat from 'videoformat'
  // 异步模式检测文件是否合规
  const canUse = videoFormat.checkWebFormatSync(file) 
   // 同步Promise模式检测文件是否合规
   videoFormat.checkWebFormat(file,{
    maxWidth:300,
    maxHeight:200
   }}).then((res)=>{
      const canUse = res;
   })
  // 返回数据
  canUse = true || false
 // 参数可选:
  checkWebFormatSync(file,params) || checkWebFormat(file,params)
  file : 上传的视频文件对象  // 必传
  params : {  // 可选
    maxWidth : 最大允许宽度, // Number类型 可选
    maxHeight: 最大允许高度 // Number类型 可选
  }
鸣谢

感谢 mp4box