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

video2text

v1.0.6

Published

本项目实现了本地批量视频(mp4)自动转音频、上传腾讯云COS、调用火山引擎ASR自动转文字并保存为txt的全流程。适用于短视频内容转写、自动听写等场景。

Downloads

14

Readme

视频转文字

项目简介

本项目实现了本地批量视频(mp4)自动转音频、上传腾讯云COS、调用火山引擎ASR自动转文字并保存为txt的全流程。适用于短视频内容转写、自动听写等场景。

功能说明

  • 批量扫描 videos 目录下的 mp4 文件
  • 自动用 ffmpeg 提取音频(mp3格式,16kHz单声道)
  • 自动上传音频到腾讯云COS,获取公网URL
  • 自动调用火山引擎ASR接口,将音频转为文字
  • 自动将识别结果保存为 txt 文件到 text 目录
  • 全流程详细日志,异常自动重试,临时文件自动清理
  • 支持 npm bin 命令,安装后可直接用 video2text 命令行运行

依赖环境

  • Node.js >= 14
  • ffmpeg(需已安装并配置到系统PATH)
  • 腾讯云COS账号及存储桶
  • 火山引擎ASR账号及API密钥

安装与配置

  1. 克隆项目并安装依赖

    git clone <本项目地址>
    cd video2text
    npm install
  2. 全局或本地安装(可选)

    • 全局安装:
      npm install -g .
    • 或在项目目录下用 npx 直接运行:
      npx video2text
  3. 准备环境变量配置 在项目根目录新建 .env 文件,内容如下(请用你自己的密钥和桶名替换):

    TENCENT_SECRET_ID=你的腾讯云SecretId
    TENCENT_SECRET_KEY=你的腾讯云SecretKey
    TENCENT_REGION=ap-beijing
    TENCENT_BUCKET=你的bucket名
    VOLC_APPID=你的火山引擎AppId
    VOLC_TOKEN=你的火山引擎Token
  4. 准备视频文件

    • 将待处理的 mp4 文件放入 videos 目录(如无请自行创建)。
  5. 确保 ffmpeg 可用

    • Windows下可在命令行输入 ffmpeg -version 验证。

使用方法

  • 全局命令行方式(推荐)

    video2text
  • npx 方式(无需全局安装)

    npx video2text
  • 直接用 node 运行

    node index.js
  • 程序会自动处理 videos 目录下所有 mp4 文件,输出的音频和文字文件自动带时间戳,结果保存在 text 目录。

  • 日志会详细显示每一步的进度和异常。

注意事项

  • 腾讯云COS和火山引擎ASR需提前开通并获取密钥。
  • 音频转码、上传、ASR均有自动重试机制,但如遇频繁失败请检查网络、密钥、配额等。
  • 临时音频文件会自动删除,节省磁盘空间。
  • 输出txt文件名自动带时间戳,防止覆盖。

常见问题

  • ffmpeg未安装或未加入PATH:请参考ffmpeg官网下载安装。
  • API密钥错误或配额不足:请检查.env配置和云服务后台。
  • COS上传失败:请检查桶名、权限、网络。
  • ASR识别失败:请检查音频格式、火山引擎配额。

联系方式

如有问题或建议,请联系: