VobSub2SRT is a simple command line program to convert .idx / .sub subtitles
into .srt text subtitles by using OCR. It is based on code from the
MPlayer project - a pretty decent movie player. Some minor parts are
copied from ffmpeg/avutil headers. Tesseract is used as OCR software.
vobsub2srt is released under the GPL3+ license. The MPlayer code included is GPL2+ licensed.
The quality of the OCR depends on the text in the subtitles. Currently the code
does not use any preprocessing. But I’m currently looking into adding filters
to improve the OCR. You can correct mistakes in the .srt files with a text
editor or a subtitle editor.
- Added conditional libPNG header check inside vobsub2srt.c++ for compatibility with NixOS and others.
- MPlayer vobsub.c memory fixes/refactor soon. Results are promising with increased speed and accuracy.
- PNG export added, cast vobsubid to avoid left shift.
- Image inversion added. Code by Ethan Dye, used with permission (https://github.com/ecdye/VobSub2SRT)
- Scaling code removed. It never did seem to work out well in my tests.
- Tesseract options added to improve accuracy somewhat.
- Scaling of subtitles implemented (try –scale)
- Final memory leak closed in vobsub.c
- Memory safety
- MPlayer verbosity separated from realtime text output
- Subtitle anti-aliasing for further accuracy enhancement.
You need libPNG, Tesseract, CMake and GCC to build vobsub2srt.
With a Debian-based distribution, you can install the dependencies with:
sudo apt-get install libpng-dev libtiff5-dev libtesseract-dev build-essential cmake pkg-config
You also need to install the tesseract data for the languages you want to use.
sudo apt-get install tesseract-lang-eng
./configure make sudo make install
Note that support for Tesseract <4 is deprecated.
Building from NixOS (Tested with 26.05):
nix-env -iA nixos.git nixos.gcc nixos.cmake nixos.tesseract nixos.libtiff nixos.libpng nixos.zlib git clone https://github.com/csingleplus/VobSub2SRT && cd VobSub2SRT cmake -B build cmake --build build sudo cmake --install build
This should install the program vobsub2srt to /usr/local/bin.
Run configure with -DCMAKE_INSTALL_PREFIX=<path> for elsewhere. You can
uninstall vobsub2srt with sudo make uninstall.
I recommend using the dynamic binary! However if you really need a static binary
you can add the flag -DBUILD_STATIC=ON to the ./configure call. But be
aware that building static binaries can be quite troublesome. You need the
static library files for tesseract, libtill, libavutils, and for their
dependencies as well. On Ubuntu 12.04 the static libraries are only included in
the dev packages! You probably also need the Gold linker.
For Ubuntu 12.04 you need the following extra packages: (but this branch likely does not work with such an old distro.)
sudo apt-get install libleptonica-dev libpng-dev libwebp-dev libgif-dev zlib1g-dev libjpeg-dev binutils-gold
If linking fails with undefined references then checking what other dependencies
your version of leptonica has is a good starting point. You can do this by
running ldd /usr/lib/liblept.so (or whatever the path to leptonica is on your
system). Add those dependencies to CMakeModules/FindTesseract.cmake.
You can build a *.deb package (Debian/Ubuntu) with make package. The package
is created in the build directory.
vobsub2srt converts subtitles in VobSub (.idx / .sub) format into subtitles
in .srt format. VobSub subtitles consist of two or three files called
Filename.idx, Filename.sub and optional Filename.ifo. To convert subtitles
simply call
vobsub2srt Filename
with Filename being the file name of the subtitle files WITHOUT the
extension (.idx / .sub). vobsub2srt writes the subtitles to a file called
Filename.srt. You can see the subtitles as they are decoded with --show.
If a subtitle file contains more than one language you can use the --lang
parameter to set the correct language (Use --langlist to find out about the
languages in the file). For some languages you might need to set the tesseract
language yourself (e.g., chi_tra/chi_sim for traditional or simplified chinese
characters). You can use --tesseract-lang to do this. Multilingual subtitles
may be written by combining langcodes as such: eng+fra. In most cases this
should however be autodetected.
If you want to dump the subtitles as images (e.g. to check for correct ocr) you
can use the --dump-png flag.
Use --help or read the manpage to get more information about the options of
vobsub2srt.
Please submit bug reports or feature requests to the issue tracker on GitHub.
If you have problems with a specific subtitle file then please check if it works in mplayer first. Also, you may need to replace the palette line in your .idx file to this, a plain white-on-black palette for better accuracy.
palette: 000000,ffffff,000000,000000,000000,ffffff,000000,000000,000000,ffffff,000000,000000,000000,ffffff,000000,000000
For bug reports please run vobsub2srt with the --verbose option set to 2,
and copy and paste the first 50~ lines from the beginning of the problem to the bug report.