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

video-ratio

v1.0.1

Published

输入视频地址,获得视频的比例和分辨率 Enter the video address to get the scale and resolution of the video

Readme

video-ratio

输入视频地址,获得视频的比例和分辨率 Enter the video address to get the scale and resolution of the video

API

videoRatio.info(videoSrc, timeout)

  • videoSrc为视频地址,
  • timeout为等待时间,单位为毫秒, 默认为2000, 如果超过timeout的时间还未返回结果,会结束等待,返回失败
videoRatio.info('https://testvideo.mp4', 2000).then((rs) => {
  if (rs.ratio) {
    // 获取视频比例信息成功
    console.log(rs);
  } else {
    // 获取失败,返回失败原因
    console.log(rs)
  }
})

接入方式

  1. npm 或 yarn 安装
npm install video-ratio

yarn add video-ratio
import { info } from 'video-ratio'

const rs = await info(src);
  1. 通过script引入, 使用video-ratio.umd.js, 构建时的入口对象为videoRatio
<script src="testcdn.com/video-ratio.umd.js"></script>
<script>
videoRatio.info(src).then((rs) => {});
</script>

返回结果的结构

正常情况
{
  ratio: '2:1',
  resolution: {
    detail: "1280x640",
    width: 1280,
    height: 640
  }
}
异常就是一段错误string

说明

实现的原理

获取视频的分辨率的宽高是根据此接口获得的HTMLVideoElement.videoWidth / HTMLVideoElement.videoHeight

只是方便接入,封装为promise返回

获取分辨率或比例异常

估计也是浏览器返回的videoWidth 跟 videoHeight有问题,这点在一些移动端浏览器上可能会出现。