Skip to main content

Subtitle Synchronization Tool

Project description

Sushi-next

Automatic shifter for SRT and ASS subtitle based on audio streams.

Python 3.13 fork of https://github.com/tp7/Sushi.

Credits to DYY-Studio for the initial v3.13 porting work.

Purpose

Imagine you've got a subtitle file synced to one video file, but you want to use these subtitles with some other video you've got via totally legal means. The common example is TV vs. BD releases, PAL vs. NTSC video and releases in different countries. In a lot of cases, subtitles won't match right away and you need to sync them.

The purpose of this script is to avoid all the hassle of manual syncing. It attempts to synchronize subtitles by finding similarities in audio streams. The script is very fast and can be used right when you want to watch something.

How it works

You need to provide two audio files and a subtitle file that matches one of those files. For every line of the subtitles, the script will extract corresponding audio from the source audio stream and will try to find the closest similar pattern in the destination audio stream, obtaining a shift value which is later applied to the subtitles.

Detailed explanation of Sushi workflow and description of command-line arguments can be found in the wiki.

Usage

The minimal command line looks like this:

python -m sushi --src hdtv.wav --dst bluray.wav --script subs.ass

Output file name is optional - "{destination_path}.sushi.{subtitles_format}" is used by default. See the usage page of the wiki for further examples.

Do note that WAV is not the only format Sushi can work with. It can process audio/video files directly and decode various audio formats, provided that ffmpeg is available. For additional info refer to the Demuxing part of the wiki.

Requirements

Sushi should work on Windows, Linux and OS X. Please open an issue if it doesn't. To run it, you have to have the following installed:

  1. Python 3.13 or higher
  2. NumPy (2.3.4 or newer)
  3. SciPy (1.16.2 or newer)
  4. OpenCV 4.4.x or newer
  5. FFmpeg (for any kind of demuxing)

Optionally, you might want:

  1. MkvExtract for faster timecodes extraction when demuxing
  2. SCXvid-standalone if you want Sushi to make keyframes
  3. Colorama to add colors to console output on Windows

Development setup (uv)

Use uv to create a local environment and install dependencies from pyproject.toml:

uv sync

Run Sushi from the managed environment:

uv run sushi --src hdtv.wav --dst bluray.wav --script subs.ass

Run tests:

uv run python run-tests.py

Installation on Windows

  1. Install Python (64 bit).
  2. Install FFmpeg.
  3. Install OpenCV.
  4. Run pip install sushi-sub-next on a terminal.
  5. Use it as sushi args… on a terminal.

If anyone wants to provide proper installation steps or a binary for Windows, please open a PR or get in contact.

Installation on Mac OS X

No binary packages are provided for OS X right now so you'll have to use the script form. Assuming you have Python, pip and homebrew installed, run the following:

brew install git opencv ffmpeg
pip3 install numpy
# install some optional dependencies
brew install f mkvtoolnix
# install sushi
pip install sushi-sub-next
# use sushi
sushi args…

Installation on Linux

If you have apt-get available, the installation process is trivial.

sudo apt-get update
sudo apt-get install git python3 python3-numpy python3-opencv ffmpeg

pip install --user sushi-sub-next
# if ~/.local/bin is in your PATH
sushi args…
# otherwise
python -m sushi args…

For other distros, pick corresponding package names for the python, numpy, and opencv dependencies.

Limitations

This script will never be able to property handle frame-by-frame typesetting. If underlying video stream changes (e.g. has different telecine pattern), you might get incorrect output.

This script cannot improve bad timing. If original lines are mistimed, they will be mistimed in the output file too.

In short, while this might be safe for immediate viewing, you probably shouldn't use it to blindly shift subtitles for permanent storing.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sushi_sub_next-0.6.6.tar.gz (45.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sushi_sub_next-0.6.6-py3-none-any.whl (27.1 kB view details)

Uploaded Python 3

File details

Details for the file sushi_sub_next-0.6.6.tar.gz.

File metadata

  • Download URL: sushi_sub_next-0.6.6.tar.gz
  • Upload date:
  • Size: 45.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for sushi_sub_next-0.6.6.tar.gz
Algorithm Hash digest
SHA256 fb5ebc630e64093014af40a8559475032eb77dd767d5383d1005e4a22c964dc2
MD5 4a847b7f5e2c26836862731ab55f3362
BLAKE2b-256 d804b03ddf1bff466f3e6e0c0679149a2dba1e1d6ca281f90bbc5ad1318a93b9

See more details on using hashes here.

File details

Details for the file sushi_sub_next-0.6.6-py3-none-any.whl.

File metadata

  • Download URL: sushi_sub_next-0.6.6-py3-none-any.whl
  • Upload date:
  • Size: 27.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for sushi_sub_next-0.6.6-py3-none-any.whl
Algorithm Hash digest
SHA256 293bb0e59879611133f5e142d9fd7dc5a21c704be8a137d4b542d250bec07f22
MD5 e701f168e363d03ab1cf0d06db8a9053
BLAKE2b-256 3824e91eda343aabfd32c2c37a5678501363cccdd86fcb5f42379f0ff36f9a00

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page