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

video-subtitle-merger

v1.1.0

Published

一个用于合并视频和字幕的命令行工具,支持硬字幕嵌入

Readme

Video Subtitle Merger

一个用于合并视频和字幕的命令行工具,支持将字幕硬编码到视频中,确保在任何播放器中都能显示字幕。

功能特性

  • 🎬 支持多种视频格式(MP4, AVI, MKV, MOV, WMV, FLV)
  • 📝 支持多种字幕格式(SRT, ASS, SSA, VTT, SUB)
  • 🔥 硬字幕嵌入,字幕直接烧录到视频画面中
  • 📊 实时进度显示
  • 🚀 命令行界面,易于集成到自动化流程
  • 🎯 批量处理多个视频文件
  • 🔧 灵活的格式配置,支持自定义扩展名

安装

全局安装

npm install -g video-subtitle-merger

本地安装

npm install video-subtitle-merger

前置要求

  • Node.js >= 14.0.0
  • FFmpeg(必须安装并添加到系统PATH中)

安装FFmpeg

Windows:

# 使用chocolatey
choco install ffmpeg

# 或者下载后手动添加到PATH
# https://ffmpeg.org/download.html

macOS:

brew install ffmpeg

Linux:

# Ubuntu/Debian
sudo apt update && sudo apt install ffmpeg

# CentOS/RHEL
sudo yum install ffmpeg

使用方法

基本用法

# 处理默认目录(./videos)中的视频文件
vmerge

# 指定输入和输出目录
vmerge -i /path/to/videos -o /path/to/output

# 显示详细信息
vmerge -v

# 指定支持的视频格式
vmerge -e "mp4,avi,mkv"

命令行参数

| 参数 | 简写 | 描述 | 默认值 | |------|------|------|--------| | --input | -i | 输入目录路径 | ./videos | | --output | -o | 输出目录路径 | ./newVideo | | --extensions | -e | 支持的视频扩展名(逗号分隔) | mp4,avi,mkv,mov,wmv,flv | | --subtitles | -s | 支持的字幕扩展名(逗号分隔) | srt,ass,ssa,vtt,sub | | --verbose | -v | 显示详细输出信息 | false | | --help | -h | 显示帮助信息 | - | | --version | -V | 显示版本信息 | - |

文件命名规则

工具会自动匹配视频文件和字幕文件:

  • 视频文件:movie.mp4
  • 对应字幕文件:movie.srt

字幕文件必须与视频文件同名(扩展名不同)。

使用示例

# 基本使用
vmerge

# 自定义目录
vmerge -i "/Users/username/Movies" -o "/Users/username/Output"

# 处理特定视频格式
vmerge -e "mp4,mkv"

# 处理特定字幕格式
vmerge -s "srt,ass"

# 完全自定义
vmerge -e "mp4,avi" -s "srt,vtt" -i "./my_videos" -o "./processed_videos"

# 详细模式
vmerge -v -i "./my_videos" -o "./processed_videos"

支持的字幕格式

| 格式 | 扩展名 | 描述 | |------|--------|------| | SubRip | .srt | 最常见的字幕格式 | | Advanced SubStation Alpha | .ass | 支持高级样式和特效 | | SubStation Alpha | .ssa | ASS的前身,基本样式支持 | | WebVTT | .vtt | Web视频标准字幕格式 | | MicroDVD | .sub | 老牌字幕格式,基于帧数 |

编程接口

如果你想在Node.js项目中使用这个工具:

const { mergeVideos } = require('video-subtitle-merger');

async function processVideos() {
  try {
    await mergeVideos({
      inputDir: './videos',
      outputDir: './output',
      videoExtensions: ['mp4', 'avi', 'mkv'],
      subtitleExtensions: ['srt', 'ass', 'vtt'],
      verbose: true
    });
    console.log('处理完成!');
  } catch (error) {
    console.error('处理失败:', error);
  }
}

processVideos();

开发

本地开发

# 克隆仓库
git clone https://gitee.com/ukSir/video-subtitle-merger.git
cd video-subtitle-merger

# 安装依赖
npm install

# 运行测试
npm start

# 链接到全局(用于测试)
npm link

项目结构

video-subtitle-merger/
├── bin/
│   └── vmerge              # 可执行文件
├── lib/
│   ├── index.js            # 主模块
│   └── video-processor.js  # 视频处理逻辑
├── videos/                 # 默认输入目录
├── newVideo/               # 默认输出目录
├── package.json
└── README.md

常见问题

1. FFmpeg未找到

确保FFmpeg已安装并添加到系统PATH中:

ffmpeg -version

2. 字幕文件未找到

检查字幕文件是否与视频文件同名,且扩展名为支持的字幕格式之一(srt, ass, ssa, vtt, sub)。

3. 权限错误

确保对输入和输出目录有读写权限。

作者信息

许可证

MIT License

贡献

欢迎提交Issue和Pull Request!

更新日志

v1.0.0

  • 初始版本发布
  • 支持基本的视频字幕合并功能
  • 命令行界面
  • 进度显示

v1.1.0

  • 新增多种字幕格式支持(SRT, ASS, SSA, VTT, SUB)
  • 添加字幕格式自定义配置
  • 改进文件路径处理
  • 更新文档和使用示例