kaegi/alass

Rust
Windows

"Automatic Language-Agnostic Subtitle Synchronization"

subtitleincorrect-subtitlesalignmenttoolapialgorithm
스타 성장
스타
1.4k
포크
74
주간 성장
+1
이슈
32
5001k
2017년 2월2020년 4월2023년 6월2026년 9월
아티팩트crates.io
README

Introduction

alass is a command line tool to synchronize subtitles to movies.

It can automatically correct

  • constant offsets
  • splits due to advertisement breaks, directors cut, ...
  • different framerates

The alignment process is not only fast and accurate, but also language-agnostic. This means you can align subtitles to movies in different languages.

alass stands for "Automatic Language-Agnostic Subtitle Synchronization". The theory and algorithms are documented in my bachelor's thesis and summarized in my bachelor's presentation.

Executable for Windows (64-bit)

Get the latest executable from here! Just download and extract the archive. The file alass.bat is the command line tool.

Executable for Linux (64-bit)

Get the latest executable from here! To run the executable, ffmpeg and ffprobe have to be installed. You can change their paths with the environment variables ALASS_FFMPEG_PATH (default ffmpeg) and ALASS_FFPROBE_PATH (default ffprobe).

Usage

The most basic command is:

$ alass movie.mp4 incorrect_subtitle.srt output.srt

You can also use alass to align the incorrect subtitle to a different subtitle:

$ alass reference_subtitle.ssa incorrect_subtitle.srt output.srt

You can additionally adjust how much the algorithm tries to avoid introducing or removing a break:

# split-penalty is a value between 0 and 1000 (default 7)
$ alass reference_subtitle.ssa incorrect_subtitle.srt output.srt --split-penalty 10

Values between 5 and 20 are the most useful. Anything above 20 misses some important splits and anything below 5 introduces many unnecessary splits.

If you only want to shift the subtitle, without introducing splits, you can use --no-splits:

# synchronizing the subtitles in this mode is very fast
$ alass movie.mp4 incorrect_subtitle.srt output.srt --no-splits

Currently supported are .srt, .ssa/.ass and .idx files. Every common video format is supported for the reference file.

Performance and Results

The extraction of the audio from a video takes about 10 to 20 seconds. Computing the alignment usually takes between 5 and 10 seconds.

The alignment is usually perfect - the percentage of "good subtitles" is about 88% to 98%, depending on how strict you classify a "good subtitle". Downloading random subtitles from OpenSubtitles.org had an error rate of about 50% (sample size N=118). Of all subtitle lines (not subtitle files) in the tested database, after synchronization

  • 50% were within 50ms of target position
  • 80% were within 100ms of target position
  • 90% were within 400ms of target position
  • 95% were within 800ms of target position

compared to a (possibly not perfect) reference subtitle.

How to compile the binary

Install Rust and Cargo then run:

# this will create the lastest release in ~/.cargo/bin/alass-cli
$ cargo install alass-cli

The voice-activity module this project uses is written in C. Therefore a C compiler (gcc or clang) is needed to compile this project.

To use alass-cli with video files, ffmpeg and ffprobe have to be installed. It is used to extract the raw audio data. You can set the paths used by alass using the environment variables ALASS_FFMPEG_PATH (default ffmpeg) and ALASS_FFPROBE_PATH (default ffprobe).

Building from Source

If you want to build and run the project from source code:

$ git clone https://github.com/kaegi/alass
$ cd alass
$ cargo build
$ cargo run -- movie.mp4 input.srt output.srt

Configuration

All parameters are shown for cargo build can also be used for cargo install and cargo run.

FFmpeg as a library

You can also link ffmpeg as a dynamic library during compile time. The library implementation can extract the audio about 2 to 3 seconds faster. Unfortunately it is harder to compile, the error handling is only very basic and might still have bugs.

You have to remove "# FFMPEG-LIB" from every line that starts with it in alass-cli/Cargo.toml. Then use:

# Important: you have to be inside `alass-cli`! Otherwise the parameters get ignored.
$ cargo build --no-default-features --features ffmpeg-library

Alias Setup

For Linux users: It is recommended to add the folder path to your system path as well as setup an alias for alass to alass-cli. Add this to your ~/.bashrc (or the setup file of your favorite shell):

export PATH="$PATH:$HOME/.cargo/bin"
alias alass="alass-cli"

Folder structure

This cargo workspace contains two projects:

  • alass-core which provides the algorithm

    It is targeted at developers who want to use the same algorithm in their project.

  • alass-cli which is the official command line tool

    It is target at end users who want to correct their subtitles.

Library Documentation

Open README from alass-core.

Notes

This program was called aligner in the past. This made it nearly impossible to find on a search engine, so alass was chosen instead.

관련 저장소
WEIFENG2333/VideoCaptioner

🎬 卡卡字幕助手 | VideoCaptioner - 基于 LLM 的智能字幕助手 - 视频字幕生成、断句、校正、字幕翻译全流程处理!- A powered tool for easy and efficient video subtitling.

PythonPyPIGNU General Public License v3.0aisubtitle
videocaptioner.cn
15.9k1.4k
jdepoix/youtube-transcript-api

This is a python API which allows you to get the transcript/subtitles for a given YouTube video. It also works for automatically generated subtitles and it does not require an API key nor a headless browser, like other selenium based solutions do!

PythonPyPIcliMIT Licenseyoutube-apisubtitles
8.2k826
smacke/ffsubsync

Automagically synchronize subtitles with video.

PythonPyPIMIT Licensesubtitlesvideo
7.9k322
mifi/editly

Slick, declarative command line video editing & API

TypeScriptnpmcliMIT Licensevideo-editoropengl
5.5k371
buxuku/SmartSub

视频转字幕、字幕翻译、AI 配音与声音克隆、字幕烧录——免费开源的一站式桌面工具。基于 Whisper / FunASR 等本地模型离线语音转文字,批量处理 + 全平台 GPU 加速,跨 Windows / macOS / Linux。Free, open-source desktop app to generate, translate, dub & burn video subtitles — local Whisper speech-to-text, AI dubbing & voice cloning, offline, GPU-accelerated.

TypeScriptnpmMIT Licensesubtitletranslate
smartsub.linxiaodong.com
5k364
zhw2590582/ArtPlayer

:art: ArtPlayer.js is a modern and full featured HTML5 video player

JavaScriptnpmMIT Licenseplayervideo
artplayer.org
4k379
ChineseSubFinder/ChineseSubFinder

自动化中文字幕下载。字幕网站支持 shooter、xunlei、arrst、a4k、SubtitleBest 。支持 Emby、Jellyfin、Plex、Sonarr、Radarr、TMM

GoGo ModulesappMIT Licensesubtitlesub
3.9k288
geeklee/srt-whiteboard-animation

将 SRT 字幕做成暖米黄纸张底的流式笔迹白板手绘动画 skill:mask 分区遮罩编排 + stream 连续笔迹(ink→color)。

PythonPyPIMIT Licenseai-skillhand-drawn
3k486
1c7/Translate-Subtitle-File

🔥(26年8月24号更新 v5.5.26 版)产品名:"译幕",用途:翻译字幕文件 .srt .ass .vtt。你只需要拖入字幕,点击翻译就行了。软件有网页版(zimoo.app)和桌面版。主要特点:用户可以自己填 API key。BYOK(Bring Your Own Key)

appasssrt
zimoo.app
2.6k195
pymedusa/Medusa

Automatic Video Library Manager for TV Shows. It watches for new episodes of your favorite shows, and when they are posted it does its magic.

PythonPyPIappGNU General Public License v3.0episodesmedusa
2k286
gnehs/subtitle-translator-electron

↔️ Translate subtitle using LLM

TypeScriptnpmappMIT Licensechatgptelectron
1.7k98
gielcobben/caption

Get Caption, start watching.

JavaScriptnpmappMIT Licensecaptionsubtitle
getcaption.co
1.3k94