@browserless/screencast

中文文档
14.0.22发布于 2026/10/13MITCommonJS近 30 天下载 3050

Capture website interactions frame-by-frame to create videos and GIFs. Perfect for demos, tutorials, and automated testing.

原始使用文档
文档目录11 节
  1. Install
  2. About
  3. What this package does
  4. Usage
  5. API
  6. Options
  7. Frame callback
  8. Examples
  9. How it fits in the monorepo
  10. Dependencies
  11. License
browserless browserless

Powered by microlink.io Last version Coverage Status NPM Status

@browserless/screencast: Browserless video recording using puppeteer.

See the screencast section on our website for more information.

Install

Using npm:

npm install @browserless/screencast --save

About

This package provides frame-by-frame video capture from browser page navigation using the Chrome DevTools Protocol. It allows you to capture individual frames during page interactions for creating GIFs, videos, or frame-by-frame analysis.

What this package does

The @browserless/screencast package allows you to:

  • Capture frames during browser navigation and interactions
  • Control recording with start/stop methods
  • Process frames individually via callback functions
  • Configure quality and format for captured frames
  • Create animations like GIFs from captured frames

Usage

const createScreencast = require('@browserless/screencast')
const createBrowser = require('browserless')

const browser = createBrowser()
const browserless = await browser.createContext()
const page = await browserless.page()

// Create screencast instance
const screencast = createScreencast(page, { 
  maxWidth: 1280, 
  maxHeight: 800 
})

// Collect frames
const frames = []
screencast.onFrame((data, metadata) => {
  frames.push({ data, metadata })
})

// Record during navigation
screencast.start()
await browserless.goto(page, { url: 'https://example.com' })
await screencast.stop()

console.log(`Captured ${frames.length} frames`)

API

createScreencast(page, options)

Creates a screencast instance for the given Puppeteer page.

Returns an object with:

MethodDescription
start()Begin capturing frames
stop()Stop capturing frames
onFrame(callback)Register frame handler

Options

Options are passed to Page.startScreencast after applying these package defaults:

OptionTypeDefaultDescription
formatstring'jpeg'Image format: 'jpeg' or 'png'
qualitynumber80JPEG quality (0-100), ignored for PNG
maxWidthnumber—Maximum width of captured frames
maxHeightnumber—Maximum height of captured frames
everyNthFramenumber1Capture every Nth frame

Frame callback

The onFrame callback receives two arguments:

screencast.onFrame((data, metadata) => {
  // data: base64-encoded image string
  // metadata: { timestamp, ... }
})

If the callback returns a promise, the next CDP frame is acknowledged after that promise settles. Use this to apply backpressure when writing frames to a slow stream or encoder.

ArgumentTypeDescription
datastringBase64-encoded frame image
metadataobjectFrame metadata including timestamp

Examples

Create a GIF from navigation

const { GifEncoder } = require('@skyra/gifenc')
const { createCanvas, Image } = require('canvas')
const sharp = require('sharp')

const width = 640
const height = 400

const canvas = createCanvas(width, height)
const ctx = canvas.getContext('2d')
const encoder = new GifEncoder(width, height)

const screencast = createScreencast(page, { 
  maxWidth: width, 
  maxHeight: height 
})

screencast.onFrame(async data => {
  const frame = Buffer.from(data, 'base64')
  const buffer = await sharp(frame).resize({ width, height }).toBuffer()
  
  const img = new Image()
  img.src = buffer
  ctx.drawImage(img, 0, 0)
  encoder.addFrame(ctx)
})

encoder.start()
screencast.start()

await browserless.goto(page, { url: 'https://example.com' })

encoder.finish()
await screencast.stop()

Capture specific frames

const screencast = createScreencast(page, {
  format: 'png',
  quality: 100,
  everyNthFrame: 5  // Capture every 5th frame
})

screencast.onFrame((data, metadata) => {
  console.log(`Frame at ${metadata.timestamp}`)
  // Save or process the frame
})

Save frames to disk

const fs = require('fs/promises')

let frameCount = 0

screencast.onFrame(async data => {
  const buffer = Buffer.from(data, 'base64')
  await fs.writeFile(`frame-${frameCount++}.jpg`, buffer)
})

screencast.start()
await page.goto('https://example.com')
await screencast.stop()

How it fits in the monorepo

This is an extended functionality package for video/animation capture:

ConsumerPurpose
User applicationsCreating GIFs, video recording, visual testing

Dependencies

PackagePurpose
null-prototype-objectClean objects without prototype chain

License

@browserless/screencast © Microlink, released under the MIT License.
Authored and maintained by Microlink with help from contributors.

The logo has been designed by xinh studio.

microlink.io · GitHub microlinkhq · X @microlinkhq

版本与发布记录

@browserless/screencast 共发布 79 个版本,首次发布于 2023/06/25;过去 12 个月发布了 37 个版本。

版本发布日期距今
14.0.22latest2026/10/1326 天前
14.0.02026/10/081 个月前
13.9.102026/09/022 个月前
13.9.02026/08/252 个月前
13.8.12026/08/172 个月前
13.7.02026/08/092 个月前

关于 @browserless/screencast 的常见问题

@browserless/screencast 是什么?

Capture website interactions frame-by-frame to create videos and GIFs. Perfect for demos, tutorials, and automated testing.

如何安装 @browserless/screencast?

在项目目录运行 npm install @browserless/screencast,或使用 pnpm add / yarn add / bun add。

@browserless/screencast 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/browserless__screencast 是否存在。

@browserless/screencast 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@browserless/screencast 需要什么版本的 Node.js?

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

@browserless/screencast 可以商用吗?

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

@browserless/screencast 的下载量有多少?

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

@browserless/screencast 还在维护吗?

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