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

@deepinnet/live-player

v1.1.4

Published

浏览器直播流渲染内核

Readme

@deepinnet/live-player 1.0

NPM version NPM downloads

无 UI 的浏览器直播流渲染内核。它只负责拉流、解封装、解码和渲染到 Canvas,不提供控制栏、水印、截图、全屏或样式。

用法

import Player from '@deepinnet/live-player';

const player = new Player({
  target: document.querySelector('#camera')!,
  source: {
    url: 'https://example.test/live/camera.flv',
  },
  muted: true,
});

player.on('error', (error) => console.error(error.code, error.message));
player.destroy();

target 可以是容器或已有的 HTMLCanvasElement。容器模式下会创建一个无 UI 的 canvas;使用 objectFit 调整视频在目标区域内的显示方式:默认 contain 保留完整画面并补黑边,cover 居中裁切以铺满区域,fill 会拉伸画面。截图会输出调整后的最终画面。

支持的输入类型为 HTTP-FLV、HLS(未加密 TS/fMP4)和 ZLMediaKit 风格 WebRTC/WHEP。source.kind 可省略:webrtc://、webrtcs:// 或 WHEP 地址识别为 WebRTC,.m3u8 识别为 HLS,其余按 FLV 处理;webrtcs:// 固定转换为 https://,webrtc:// 使用当前页面的 HTTP(S) 协议。显式传入 kind 可覆盖识别结果。HLS 主播放列表固定使用最高 BANDWIDTH Variant,不执行自适应切换。

decoder 可选择 webcodecs、mse 或 adapter,默认 WebCodecs。fMP4 HLS 使用 MSE;FLV 和 TS HLS 需要 WebCodecs 或调用方注入的 fallback.decoderFactory。默认模式检测到 PCMA、PCMU、MP2、AC-3、G.726、DTS 时只触发 warning 事件并继续视频播放;设置 decoder: 'adapter' 后才使用外部 adapter(例如 @deepinnet/live-player-ffmpeg)解码为 PCM。H.265 是否可用取决于浏览器原生能力。

对非 ENDLIST 的 TS HLS,外部 adapter 默认使用低延迟控制:从最新完整分片起播,目标本地管线滞后为 800ms,超过 2 秒时从最近关键帧重同步。普通数秒 HLS 分片的端到端延迟仍受服务端分片时长限制。需要完整帧时使用 quality 模式:

const player = new Player({
  decoder: 'adapter',
  fallback: { decoderFactory },
  live: {
    mode: 'latency',
    targetLatencyMs: 800,
    maxLatencyMs: 2000,
    recovery: 'keyframe-reset',
  },
  source: { url: 'https://example.test/live/index.m3u8' },
  target,
});
live: {
  mode: 'quality', // 不执行实时追赶丢帧,允许本地缓冲增长
  segmentStartupBufferCount: 2, // 累计 2 个完整 TS 分片后起播
}

segmentStartupBufferCount 默认为 0;大于 0 时优先于 segmentStartupBufferDurationMs。将其设回 0 可继续按累计分片时长控制起播。

旧版 new LivePlayer(container, { videoUrl }) API 已在 1.0 移除。

Development

# install dependencies
$ pnpm install

# develop library by docs demo
$ pnpm start

# build library source code
$ pnpm run build

# build library source code in watch mode
$ pnpm run build:watch

# build docs
$ pnpm run docs:build

# Locally preview the production build.
$ pnpm run docs:preview

# check your project for potential problems
$ pnpm run doctor

LICENSE

MIT