Giter Site home page Giter Site logo

thedod / rtl-subtitle Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nabikaz/rtl-subtitle

1.0 0.0 0.0 6 KB

Right-to-left subtitles by adding the RLE character to each sentence. Doing this is required when integrating subtitles by video editors such as ffmpeg.

License: MIT License

Python 100.00%

rtl-subtitle's Introduction

Right-to-left subtitles

This script solves the problem of formatting subtitles in right-to-left languages, making them compatible with video editing software like FFmpeg. By adding the RLE character at the beginning of each text line while preserving the timestamps, it ensures that the subtitles display correctly in the intended right-to-left direction when overlaid on video content. This formatting is crucial for maintaining the legibility and visual integrity of subtitles in languages that use a right-to-left writing system.

The UTF-16 encoding character 0x202B (RLE) (which stands for the "RIGHT-TO-LEFT EMBEDDING" control character) is only added to text-containing lines and not to timestamp lines in your SRT file.

Usage

Make sure to replace sample_subtitle.srt with the path to your input SRT file and output_subtitle.srt with the desired output file path. Then just run:

python rtl-subtitle.py

FFmpeg

Integrate right-to-left subtitles with ffmpeg if you want. Use this simple command:

ffmpeg -i "sample.mp4" -vf "subtitles='output_subtitle.srt'" "sample_output.mp4"

Or this more advanced command:

ffmpeg -i "sample.mp4" -vf "subtitles='output_subtitle.srt':force_style='FontName=vazir,Fontsize=30,PrimaryColour=&Hffffff&'" -ss 00:00:00 -to 00:00:20 -c:v libx264 -c:a aac -b:v 300k -b:a 48k -y "sample_output.mp4"

Sample

Before:

mpc-hc64_3FRBHbsOTc

After RTL:

mpc-hc64_WPTwJY4e5X

License

By https://twitter.com/NabiKAZ

MIT License

Donation

If this project was useful for you and you are willing, you can make me happy by giving a Star at the top of this GitHub page.
Also this is my wallet address for Donate:
USDT (TRC20): TEHjxGqu5Y2ExKBWzArBJEmrtzz3mgV5Hb

rtl-subtitle's People

Contributors

nabikaz avatar

Stargazers

my PROJECTX avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.