Automatic subtitle shifter based on audio
Project description
Sushi
Automatic shifter for SRT and ASS subtitle based on audio streams.
Python 3 fork of https://github.com/tp7/Sushi.
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 sushi.py --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:
- Python 3.5 or higher
- NumPy (1.8 or newer)
- OpenCV 2.4.x or newer
Optionally, you might want:
- FFmpeg for any kind of demuxing
- MkvExtract for faster timecodes extraction when demuxing
- SCXvid-standalone if you want Sushi to make keyframes
- Colorama to add colors to console output on Windows
Installation on Windows
Because the "maintainer" of this fork does not run Windows and is not interested in providing binaries, you are kind of on your own. The following steps are untested (see requirements earlier):
- Install Python (64 bit).
- Install OpenCV.
- Run
pip install sushi-sub colorama
on a terminal. - 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 3, pip and homebrew installed, run the following:
brew tap homebrew/science
brew install git opencv
pip3 install numpy
# install some optional dependencies
brew install ffmpeg mkvtoolnix
# install sushi
pip3 install sushi-sub
# use sushi
sushi args…
If you don't have pip, you can install numpy with homebrew, but that will probably add a few more dependencies. You will also need to install sushi manually.
brew tap homebrew/python
brew install numpy
# fetch sushi
git clone https://github.com/FichteFoll/sushi
# run from source
python3 -m sushi args…
# OR install globally (for your user)
python3 setup.py install --user
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
pip3 install --user sushi-sub
# if ~/.local/bin is in your PATH
sushi args…
# otherwise
python3 -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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file sushi-sub-0.6.2.tar.gz
.
File metadata
- Download URL: sushi-sub-0.6.2.tar.gz
- Upload date:
- Size: 26.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.8.1 pkginfo/1.8.3 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.64.0 CPython/3.10.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 32e6106bfd71808e890f6ec7d2a5a2565294af904bccab6d65b257ba522eae66 |
|
MD5 | bb033f5e4cb8f6171d1e2a5c38711cd6 |
|
BLAKE2b-256 | 9fdc785a74fbed9fa7931ff1c0a62601b06c1c0521fa0ff63d8caaa70aeff4b8 |
File details
Details for the file sushi_sub-0.6.2-py3-none-any.whl
.
File metadata
- Download URL: sushi_sub-0.6.2-py3-none-any.whl
- Upload date:
- Size: 27.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.8.1 pkginfo/1.8.3 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.64.0 CPython/3.10.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 61961040eb6e7116d749302098b77567ddcf371ab88a4756b22a23e8b487692c |
|
MD5 | b07e175cc11c4a349520cb765cfc3409 |
|
BLAKE2b-256 | 35a13e733b426e6a97ac77e6b56d037079a77ff44ff58990d5fef69248903281 |