Skip to content

Subtitle Synchronization raw script to sync subtitles with audio/video

License

Notifications You must be signed in to change notification settings

kushtej/subsync

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Subtitle Synchronization

contributions welcome

We all have faced problem when it comes to syncing subtitles with a movie or a video we are watching.This is a raw script to sync subtitles with audio/video written in Python.

Setting up the Package/Script :

There are 2 options for downloading and setting up subsync in your machine :

  1. Downloading the subsync Package.
  2. Downloading the subsync script(lite-version)

1.Setting up the package :

Step 1 :

Download the subsync script from https://github.com/kushtej/subsync.

OR

Download from the latest Release of subsync from https://github.com/kushtej/subsync/releases/tag/0.1

Step 2 : Type the following commands in the Terminal.

$ chmod +x setup.sh
$ ./setup.sh

2.Setting up the Script(lite-verision) :

Step 1 : Download the subsync script from https://kushtej.github.io/subsync.

Step 2 : Type the following commands in the Terminal.

$ chmod +x subsync
$ mv subsync /usr/local/bin/

Usage :

The subsync script contains 2 options

  • --sync-time
  • --calibrate

The script also contains --help option to elaborate the content in the terminal.

1. subsync --sync-time

The --sync-time option finds haste or delay between video/audio and subtitle. The input to this option is in minutes and seconds of subtitle and video-audio. The output is the time difference between the video-audio and subtitle. This output can then be used in the --calibrate option to sync the subtitle. The difference will be -seconds if its a haste and +seconds if its a delay.

Sample Output :

(i). If in a movie, The subtitle starts at 00:01:33 (HH:MM:SS) and audio/video starts at 00:01:54

$ subsync --sync-time

Type : INT (Input in number only)
Enter subtitle start min : 1
Enter subtitle start min : 33
Enter video-audio start min : 1
Enter video-audio start sec : 54

Then, The Time Difference is in haste and the output would look like this.

Time Difference : 21.0 seconds

(ii). If in a movie, The subtitle starts at 00:01:32 (HH:MM:SS) and audio/video starts at 00:01:17

$ subsync --sync-time

Type : INT (Input in number only)
Enter subtitle start min : 1
Enter subtitle start min : 32
Enter video-audio start min : 1
Enter video-audio start sec : 17

Then, The Time Difference is in haste and the output would look like this.

Time Difference : -15.0 seconds

2. subsync --calibrate

The --calibrate option is used to sync the subtitle with the audio-video with the delay/haste seconds found in --sync-time option. It inputs subtitlename.srt and the number of seconds in delay or haste. Then, The file is calibrated to the given time and the output file is generated by the name of sync_subtitlename.srt

Sample output (Delay) :

$ subsync --calibrate

  Type : TEXT (Input in text only)
  File Name : subtitlename.srt
  Type : INT (Input in number only)
  Delay[+]/Haste[-] Seconds : 21

  File Name : subtitlename.srt
  Delay : 21 seconds

  SUCCESS!
  File Generated : sync_subtitlename.srt

Sample output (Haste) :

$ subsync --calibrate

  Type : TEXT (Input in text only)
  File Name : subtitlename.srt
  Type : INT (Input in number only)
  Delay[+]/Haste[-] Seconds : -21

  File Name : subtitlename.srt
  Hast : 21 seconds

  SUCCESS!
  File Generated : sync_subtitlename.srt

Note: The script and documentation is only refrenced to linux system.

Note: The below code is a raw script and needs revision.If you notice any error in the code or optimize the code then feel free to post it in the comment section or collaborate to the gist.

Thank You for using my code :)