Skip to main content

SrtMerger is a tool to merge two or more subtitle (.srt) files together.

Project description

SrtMerger

A command-line tool to merge multiple SRT subtitle files with customizable colors, positions, and encodings.

PyPI version Python versions License

s

Subtitle merger is a tool for merging two or more subtitles for videos. SRT Merger allows you to merge subtitle files, no matter what language are the subtitles encoded in. The result of this merge will be a new subtitle file which will display subtitles from each merged file.

Features

  • Merge multiple SRT subtitle files into one
  • Customize subtitle colors for each input file
  • Set subtitle position (top/bottom) individually
  • Support for different file encodings
  • Set global defaults for all files
  • Simple and intuitive command-line interface

Installation

pip install srtmerger

Usage

Python

Running in your Python script:

 from srtmerger import Merger


 m = Merger(output_path="new.srt")
 m.add('fa.srt', color="yellow", encoding="windows-1256")
 m.add('en.srt')
 m.merge()

Bash

The basic syntax is:

srtmerger [global options] file1.srt[:options] file2.srt[:options] ...

Each subtitle file can have its own configuration using colon-separated options:

  • e=VALUE, encoding=VALUE: Set the file encoding (e.g., utf-8, utf-16)
  • c=VALUE, color=VALUE: Set the subtitle color
  • top: Position the subtitles at the top of the screen
Global Options
  • -o, --output: Set path for the output file
  • -e, --output-encoding: Set encoding for the output file
  • -E, --default-encoding: Set default encoding for all files
  • -C, --default-color: Set default color for all files
  • -T, --default-top: Set default top position for all files

Examples

  1. Basic merge of two subtitle files:
srtmerger sub1.srt sub2.srt -o output.srt
  1. Set specific options for each file:
srtmerger sub1.srt:encoding=utf-8:color=yellow:top sub2.srt:color=blue --output output.srt

The above command is equivalent to:

srtmerger sub1.srt:e=utf-8:c=yellow:top sub2.srt:c=blue -o output.srt
  1. Use global defaults with some overrides:
srtmerger -o output.srt -E utf-8 -C white sub1.srt sub2.srt:color=blue

Development

Prerequisites

  • Python 3.11 or higher

Setting up Development Environment

  1. Clone the repository:
git clone https://github.com/iraj-jelo/srtmerger.git
cd srtmerger
  1. Install in editable mode with test dependencies:
pip install -e .

Running Tests

Run all tests:

python -m unittest discover -s tests -v

Run a specific test file:

python -m unittest tests/test_main.py -v

Contributing

  1. Fork the repository
  2. Create your feature branch: git checkout -b feature/my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin feature/my-new-feature
  5. Submit a pull request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Authors

  • iraj-jelo - Initial work - GitHub

Changelog

[0.1.0] - 2025-01-12

  • Initial release
  • Basic subtitle merging functionality
  • Support for custom colors and positioning
  • File encoding options
  • Command-line interface

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

srtmerger-0.1.0.tar.gz (63.9 kB view details)

Uploaded Source

Built Distribution

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

srtmerger-0.1.0-py3-none-any.whl (20.4 kB view details)

Uploaded Python 3

File details

Details for the file srtmerger-0.1.0.tar.gz.

File metadata

  • Download URL: srtmerger-0.1.0.tar.gz
  • Upload date:
  • Size: 63.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for srtmerger-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2bf2f6c4a35a53978b82c0c337f2843762cb47169c2621d916dfcfb98bc2a96d
MD5 9dc6007e7aadf26ade8b587ac0e0ecb1
BLAKE2b-256 0b9741e4f4071affae49db24e82f5d0686a4ce93a2f534be5b63dd781c3d3f7b

See more details on using hashes here.

Provenance

The following attestation bundles were made for srtmerger-0.1.0.tar.gz:

Publisher: python-publish.yml on iraj-jelo/srtmerger

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file srtmerger-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: srtmerger-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 20.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for srtmerger-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 46772d7afb2705a1356a1502ecfd792c38b6b3850ed5e3aa16fe0085b8f8b270
MD5 f21f257a2b1da47b95b423a3a54dd98a
BLAKE2b-256 c77be203ba03a935698d02514452cf83324185afbb84c29eb5b58ab62ed962be

See more details on using hashes here.

Provenance

The following attestation bundles were made for srtmerger-0.1.0-py3-none-any.whl:

Publisher: python-publish.yml on iraj-jelo/srtmerger

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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