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 🙏

© 2025 – Pkg Stats / Ryan Hefner

node-ffmpeg-api

v1.0.0

Published

A fluent API to FFMPEG

Downloads

5

Readme

Node FFmpeg API

一个流畅的 FFmpeg Node.js API,提供简单易用的接口来操作 FFmpeg 命令行工具。

🎉 现已完全支持 TypeScript! 享受完整的类型安全和现代开发体验。

🚀 特性

  • 完整的 TypeScript 支持 - 类型安全和智能提示
  • 流畅的 API 设计 - 链式调用,易于使用
  • 100% 向后兼容 - 现有 JavaScript 代码无需修改
  • 丰富的功能 - 音频、视频、滤镜、流处理等
  • 事件驱动 - 进度监控和错误处理

📦 安装

npm install node-ffmpeg
# 或
pnpm install node-ffmpeg

🚀 快速开始

JavaScript 使用

const ffmpeg = require('node-ffmpeg');

// 基本转换
ffmpeg()
  .input('input.mp4')
  .audioCodec('aac')
  .videoCodec('libx264')
  .size('640x480')
  .save('output.mp4', (err) => {
    if (err) console.error('转换失败:', err);
    else console.log('转换完成!');
  });

TypeScript 使用

import { ffmpeg, FfmpegCommand } from 'node-ffmpeg';

const command: FfmpegCommand = ffmpeg()
  .input('input.mp4')
  .audioCodec('aac')
  .videoBitrate('1000k')
  .fps(30)
  .size('1280x720')
  .save('output.mp4', (err?: Error) => {
    if (err) console.error('转换失败:', err.message);
    else console.log('转换完成!');
  });

📚 文档

🛠 前提条件

确保您的系统上已安装 FFmpeg

设置 FFmpeg 路径

import { ffmpeg } from 'node-ffmpeg';

// 如果 FFmpeg 不在 PATH 中,可以手动设置
ffmpeg.setFfmpegPath('/path/to/ffmpeg');
ffmpeg.setFfprobePath('/path/to/ffprobe');

🎯 基本功能

音频处理

ffmpeg()
  .input('audio.wav')
  .audioCodec('mp3')
  .audioBitrate(192)
  .audioChannels(2)
  .save('audio.mp3');

视频处理

ffmpeg()
  .input('video.avi')
  .videoCodec('libx264')
  .videoBitrate('2000k')
  .fps(30)
  .size('1920x1080')
  .save('video.mp4');

事件监听

ffmpeg()
  .input('input.mp4')
  .output('output.mp4')
  .on('start', (commandLine) => {
    console.log('FFmpeg 进程启动:', commandLine);
  })
  .on('progress', (progress) => {
    console.log('进度:', progress.percent + '%');
  })
  .on('end', () => {
    console.log('处理完成');
  })
  .on('error', (err) => {
    console.error('处理错误:', err);
  })
  .run();

🌟 示例

查看 examples 文件夹 获取更多实际使用示例:

🤝 贡献

欢迎提交 Pull Request 和 Issue!

📄 许可证

MIT


更多详细信息请查看 完整文档