A tool to detect subtitle languages in media files
Project description
Subtitle Detector
A tool to detect the language of subtitles in media files and standalone subtitle files.
Features
- Detect languages in embedded subtitles (VOB, ASS, PGS)
- Analyze standalone subtitle files
- Support for multiple subtitle tracks
- Works with text-based and image-based subtitles
- Uses metadata when available, falls back to content detection
Installation
pip install subdetector
System Requirements
Before using subdetector, install the required system dependencies:
Ubuntu/Debian
sudo apt install ffmpeg tesseract-ocr
macOS
brew install ffmpeg tesseract
Windows
Download and install:
Usage
Basic Commands
# Analyze all subtitle tracks in a media file
subdetector movie.mkv
# Analyze a specific subtitle track (by index)
subdetector movie.mkv -t 2
# Analyze a standalone subtitle file
subdetector subtitle.srt
Command-Line Options
usage: subdetector [-h] [-t TRACK] file
Detect subtitle languages in media files or subtitle files
positional arguments:
file Media file or subtitle file path
optional arguments:
-h, --help show this help message and exit
-t TRACK, --track TRACK
Specific subtitle track index to analyze (for media files only)
Examples
Analyzing a Media Container with Multiple Subtitle Tracks
$ subdetector movie.mkv
Detecting subtitle language in: movie.mkv
Results:
Stream #2 (subrip): en [metadata]
Stream #3 (ass): fr [text-detection]
Stream #4 (hdmv_pgs_subtitle): ja [ocr-detection]
Analyzing a Specific Subtitle Track
$ subdetector movie.mkv -t 3
Detecting subtitle language in: movie.mkv
Results:
Stream #3 (ass): fr [text-detection]
Analyzing a Standalone Subtitle File
$ subdetector english_subtitles.srt
Detecting subtitle language in: english_subtitles.srt
Results:
Subtitle file (srt): en [text-detection]
Supported Formats
-
Text-based subtitles:
- SubRip (
.srt) - Advanced SubStation Alpha (
.ass) - SubStation Alpha (
.ssa) - WebVTT (
.vtt)
- SubRip (
-
Image-based subtitles:
- HDMV Presentation Graphic Stream (
.sup,.pgs) - DVD-Video Object (
.sub,.idx)
- HDMV Presentation Graphic Stream (
Detection Method
The tool uses several methods to detect the subtitle language:
- Metadata Detection: Checks if the language is specified in the file's metadata.
- Text Detection: For text-based subtitles, analyzes the subtitle content.
- OCR Detection: For image-based subtitles, performs OCR on extracted frames.
Troubleshooting
No Subtitle Tracks Found
If the tool reports no subtitle tracks found:
- For MKV files: Ensure subtitles are properly muxed.
- For standalone files: Check if the file is corrupted.
Unknown Language
If the language is reported as "Unknown":
- For text subtitles: The subtitle may have too little text or highly specialized terminology.
- For image subtitles: OCR may have failed due to complex fonts or background.
FFmpeg or Tesseract Errors
Ensure that both FFmpeg and Tesseract OCR are properly installed and in your PATH.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
MIT
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file subdetector-0.1.0.tar.gz.
File metadata
- Download URL: subdetector-0.1.0.tar.gz
- Upload date:
- Size: 6.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e1f919b76ddd2decc0efde6cb1b90033f159993b40f27e8c091a8fc2f15d04b4
|
|
| MD5 |
176b1d95d80f2870fcf8575d67d11d9d
|
|
| BLAKE2b-256 |
a691acff03cbd14d175186b3f780d84716aaf89693bab09eea41876a3e73a716
|
Provenance
The following attestation bundles were made for subdetector-0.1.0.tar.gz:
Publisher:
python-publish.yml on regix1/subdetector
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
subdetector-0.1.0.tar.gz -
Subject digest:
e1f919b76ddd2decc0efde6cb1b90033f159993b40f27e8c091a8fc2f15d04b4 - Sigstore transparency entry: 215342163
- Sigstore integration time:
-
Permalink:
regix1/subdetector@6cc72e3208a6477ed49939bcbd1414f2cc957902 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/regix1
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@6cc72e3208a6477ed49939bcbd1414f2cc957902 -
Trigger Event:
release
-
Statement type:
File details
Details for the file subdetector-0.1.0-py3-none-any.whl.
File metadata
- Download URL: subdetector-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
45a53f02a21a67dfe547513143bf169ca94a4bea373284cddac35a423cd99fc6
|
|
| MD5 |
53facc9cb9ec2ece808566b973fa3456
|
|
| BLAKE2b-256 |
b5b24301a66b12c3aa5843caad3f8af39607ab311a96037c480a30f09e5bc9c0
|
Provenance
The following attestation bundles were made for subdetector-0.1.0-py3-none-any.whl:
Publisher:
python-publish.yml on regix1/subdetector
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
subdetector-0.1.0-py3-none-any.whl -
Subject digest:
45a53f02a21a67dfe547513143bf169ca94a4bea373284cddac35a423cd99fc6 - Sigstore transparency entry: 215342164
- Sigstore integration time:
-
Permalink:
regix1/subdetector@6cc72e3208a6477ed49939bcbd1414f2cc957902 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/regix1
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@6cc72e3208a6477ed49939bcbd1414f2cc957902 -
Trigger Event:
release
-
Statement type: