video-subtitle-remover README

The project's README from github.com/YaoFANGUK/video-subtitle-remover. As one markdown file: README.md.

简体中文 | English

VSR Logo
YaoFANGUK%2Fvideo-subtitle-remover | Trendshift YaoFANGUK%2Fvideo-subtitle-remover | Trendshift

项目简介

License python version support os Docker

Video-subtitle-remover (VSR) 是一款基于AI技术,将视频中的硬字幕去除的软件。 主要实现了以下功能:

demo.png

使用说明:

下载地址:Release

预构建包对比说明:

预构建包名 Python Paddle Torch 环境 支持的计算能力范围
vsr-windows-cpu.7z 3.12 3.0.0 2.7.0 通用 通用
vsr-windows-directml.7z 3.12 3.0.0 2.4.1 Windows 非Nvidia显卡 通用
vsr-windows-nvidia-cuda-11.8.7z 3.12 3.0.0 2.7.0 CUDA 11.8 3.5 – 8.9
vsr-windows-nvidia-cuda-12.6.7z 3.12 3.0.0 2.7.0 CUDA 12.6 5.0 – 8.9
vsr-windows-nvidia-cuda-12.8.7z 3.12 3.0.0 2.7.0 CUDA 12.8 5.0 – 9.0+

NVIDIA官方提供了各GPU型号的计算能力列表,您可以参考链接: CUDA GPUs 查看你的GPU适合哪个CUDA版本

Docker版本:

  # Nvidia 10 20 30系显卡
  docker run -it --name vsr --gpus all eritpchy/video-subtitle-remover:1.4.0-cuda11.8 python backend/main.py -i test/test.mp4 -o test/test_no_sub.mp4

  # Nvidia 40系显卡
  docker run -it --name vsr --gpus all eritpchy/video-subtitle-remover:1.4.0-cuda12.6 python backend/main.py -i test/test.mp4 -o test/test_no_sub.mp4

  # Nvidia 50系显卡
  docker run -it --name vsr --gpus all eritpchy/video-subtitle-remover:1.4.0-cuda12.8 python backend/main.py -i test/test.mp4 -o test/test_no_sub.mp4

  # AMD / Intel 独显 集显
  docker run -it --name vsr --gpus all eritpchy/video-subtitle-remover:1.4.0-directml python backend/main.py -i test/test.mp4 -o test/test_no_sub.mp4

  # CPU
  docker run -it --name vsr --gpus all eritpchy/video-subtitle-remover:1.4.0-cpu python backend/main.py -i test/test.mp4 -o test/test_no_sub.mp4

  # 导出视频
  docker cp vsr:/vsr/test/test_no_sub.mp4 ./

命令行参数:

Video Subtitle Remover Command Line Tool

options:
  -h, --help            show this help message and exit
  --input INPUT, -i INPUT
                        Input video file path
  --output OUTPUT, -o OUTPUT
                        Output video file path (optional)
  --subtitle-area-coords YMIN YMAX XMIN XMAX, -c YMIN YMAX XMIN XMAX
                        Subtitle area coordinates (ymin ymax xmin xmax). Can be specified multiple times for multiple areas.
  --inpaint-mode {sttn-auto,sttn-det,lama,propainter,opencv}
                        Inpaint mode, default is sttn-auto

演示

demo2.gif

demo.gif

源码使用说明

1. 安装 Python

请确保您已经安装了 Python 3.12+。

2. 安装依赖文件

请使用虚拟环境来管理项目依赖,避免与系统环境冲突。

(1)创建虚拟环境并激活

python -m venv videoEnv
videoEnv\\Scripts\\activate
source videoEnv/bin/activate

3. 创建并激活项目目录

切换到源码所在目录:

cd <源码所在目录>

例如:如果您的源代码放在 D 盘的 tools 文件夹下,并且源代码的文件夹名为 video-subtitle-remover,则输入:

cd D:/tools/video-subtitle-remover-main

4. 安装合适的运行环境

本项目支持 CUDA (NVIDIA显卡加速)、CPU (无 GPU)、 DirectML (AMD、Intel等GPU/APU加速) 和 macOS (Apple Silicon) 四种运行模式。

(1) CUDA(NVIDIA 显卡用户)

请确保您的 NVIDIA 显卡驱动支持所选 CUDA 版本。

(2) DirectML(AMD、Intel等GPU/APU加速卡用户)
(3) CPU 运行(无 GPU 加速)
(4) macOS 运行 (Apple Silicon)

4. 运行程序

python gui.py
python ./backend/main.py

常见问题

  1. 提取速度慢怎么办

修改backend/config.py中的参数,可以大幅度提高去除速度

MODE = InpaintMode.STTN  # 设置为STTN算法
STTN_SKIP_DETECTION = True # 跳过字幕检测,跳过后可能会导致要去除的字幕遗漏或者误伤不需要去除字幕的视频帧
  1. 视频去除效果不好怎么办

修改backend/config.py中的参数,尝试不同的去除算法,算法介绍

  • InpaintMode.STTN 算法:对于真人视频效果较好,速度快,可以跳过字幕检测
  • InpaintMode.LAMA 算法:对于图片效果最好,对动画类视频效果好,速度一般,不可以跳过字幕检测
  • InpaintMode.PROPAINTER 算法: 需要消耗大量显存,速度较慢,对运动非常剧烈的视频效果较好
MODE = InpaintMode.STTN  # 设置为STTN算法
# 相邻帧数, 调大会增加显存占用,效果变好
STTN_NEIGHBOR_STRIDE = 10
# 参考帧长度, 调大会增加显存占用,效果变好
STTN_REFERENCE_LENGTH = 10
# 设置STTN算法最大同时处理的帧数量,设置越大速度越慢,但效果越好
# 要保证STTN_MAX_LOAD_NUM大于STTN_NEIGHBOR_STRIDE和STTN_REFERENCE_LENGTH
STTN_MAX_LOAD_NUM = 30
MODE = InpaintMode.LAMA  # 设置为STTN算法
LAMA_SUPER_FAST = False  # 保证效果

如果对模型去字幕的效果不满意,可以查看design文件夹里面的训练方法,利用backend/tools/train里面的代码进行训练,然后将训练的模型替换旧模型即可

  1. 7z文件解压错误

解决方案:升级7-zip解压程序到最新版本

  1. Mac版本运行报错:Error "bad CPU type in executable"

解决方案:打开控制台输入softwareupdate --install-rosetta 安装rosetta

赞助

video-subtitle-remover (YaoFANGUK/video-subtitle-remover)

Searching Database…

What is this?Video-subtitle-remover (VSR) is an AI tool that removes hard-coded subtitles and text-like watermarks from videos and images, outputting the result at the original resolution without calling any third-party API.
Is this a GUI app or a command-line tool?Both: it ships a graphical interface and a CLI version so you can run it either way.
How do I get it running?Download the prebuilt archive, unzip and run it directly; if that fails, install from source by setting up a conda/venv environment matching your platform and GPU.
What do I need installed before running it?Python 3.12+ is required, plus one of four backend setups: CUDA 11.8 with cuDNN 8.6.0 for NVIDIA GPUs, DirectML for AMD/Intel GPUs on Windows, plain CPU mode, or the native macOS (Apple Silicon) mode.
Does subtitle removal always work well?Quality depends heavily on the chosen inpainting algorithm, and on Apple Silicon the default OCR subtitle-detection model (PP-OCRv4-Server) is noticeably less accurate, so a different model is recommended there.
Which operating systems and GPUs does it support?It runs on Windows, Linux and macOS, with GPU acceleration via CUDA (NVIDIA) or DirectML (AMD/Intel), or in CPU-only mode; macOS Intel should use CPU mode since GPU is actually slower there.
What's the difference between the STTN, LAMA and ProPainter removal algorithms?STTN works well and fast on real-footage video and can skip subtitle detection; LAMA gives the best results on images and animated video but can't skip detection; ProPainter handles heavy motion well but needs a lot of VRAM and runs slower.
Can it extract subtitles instead of just removing them?Yes, it's designed to pair with the companion project video-subtitle-extractor (VSE) for pulling subtitle text out of the original video.
Can I remove watermarks from a batch of images, not just video?Yes, it supports selecting multiple images at once to batch-remove watermark text from them.
Can I limit removal to a specific area of the screen?Yes, you can pass a custom subtitle region to only erase text in that area, or leave it unset to auto-detect and remove all text in the frame.
Creator
YaoFANGUK
Size
1.4 GB
Stars
13.3K
Age
2y
Commits · 90 Days