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-stream-snap

v0.0.5

Published

Capture the first frame from video streams (HLS/RTMP/FLV)

Readme

video-stream-snap

一个轻量级的视频流截图工具,支持从HLS、RTMP和FLV流中快速捕获第一帧画面。

特性

  • 🚀 支持多种流媒体格式:HLS、RTMP、FLV
  • 🎯 自动检测流类型并使用对应解码器
  • ⚡️ 异步操作,支持超时控制
  • 🎨 可配置输出图片格式和质量
  • 🖼 支持黑帧检测
  • 📦 支持TypeScript
  • 🔧 可自定义视频元素

安装

# 使用 npm
npm install video-stream-snap

# 使用 yarn
yarn add video-stream-snap

# 使用 pnpm
pnpm add video-stream-snap

# 使用 bun
bun add video-stream-snap

使用方法

import StreamSnap from 'video-stream-snap';

// 基本用法
try {
  const imageDataUrl = await StreamSnap.capture('https://example.com/stream.m3u8');
  console.log('截图成功:', imageDataUrl);
} catch (error) {
  console.error('截图失败:', error);
}

// 使用配置选项
const options = {
  timeout: 10000,        // 超时时间(毫秒)
  quality: 0.9,          // 输出图片质量(0-1)
  mimeType: 'image/png', // 输出图片格式
  skipBlackFrame: true   // 跳过黑帧检测
};

const imageDataUrl = await StreamSnap.capture('rtmp://example.com/live', options);

API文档

StreamSnap.capture(streamUrl, options?)

捕获视频流的第一帧画面。

参数

  • streamUrl (string): 视频流地址
  • options (StreamSnapOptions): 可选配置项

StreamSnapOptions

interface StreamSnapOptions {
  /** 超时时间(毫秒),默认5000 */
  timeout?: number;
  
  /** 输出图片质量(0-1),默认0.8 */
  quality?: number;
  
  /** 输出图片类型,默认'image/jpeg' */
  mimeType?: 'image/jpeg' | 'image/png' | 'image/webp';
  
  /** 跳过黑帧检测,默认false */
  skipBlackFrame?: boolean;
  
  /** 自定义视频元素 */
  videoElement?: HTMLVideoElement;
}

返回值

返回一个Promise,解析为base64编码的图片数据URL。

开发指南

环境要求

  • Node.js >= 16
  • Bun >= 1.1.38

开发流程

  1. 安装依赖
bun install
  1. 开发模式
bun run dev
  1. 构建
bun run build

测试

项目使用Vitest进行测试。

# 运行测试
bun test

# 查看测试覆盖率
bun run coverage

# 使用UI界面运行测试
bun run test:ui

许可证

MIT © zhangjingjing207