Skip to content

Latest commit

 

History

History
58 lines (45 loc) · 1.54 KB

File metadata and controls

58 lines (45 loc) · 1.54 KB

svga-node

Adapted from svga/SVGAPlayer-Web-Lite to support SVGA processing in Node.js

Example

const buffer = fs.readFileSync(filePath)
const svga = await parser(buffer)
const result = await render(svga)
for (const i in result) {
  const filePath = path.join(outputFolder, `${i}.png`)
  const ws = fs.createWriteStream(filePath)
  const stream = result[i].createPNGStream()
  stream.pipe(ws)
  ws.on('finish', () => console.log(`Done ${i}.png`))
}

API

Parser

parser(data: ArrayBuffer | Uint8Array): Promise<VideoEntity>

Render

render(videoEntity: Video, opts?: PlayerConfigOptions): Promise<Canvas[]>

For more details on available Canvas methods, please refer to the node-canvas documentation

PlayerConfigOptions

interface PlayerConfig {
  /**
   * Playback mode. Default: 'forwards'.
   */
  playMode: 'forwards' | 'fallbacks'
  /**
   * The frame number where playback starts. Default: 0
   */
  startFrame: number
  /**
   * The frame number where playback ends. Default: 0
   * NOTE: If the value is 0 or less, playback will proceed to the very end
   */
  endFrame: number
}

Copyright

The test file example/taffy.svga is the property of 永雏塔菲 and 上海幻电信息科技有限公司. It is used here for demonstration purposes only. If there is any copyright infringement, please contact me, and the file will be removed immediately.