Mint Serena 64 bit using the Mate desktop environment. Most of the following scripts will run on this machine, although some have only been tested with the Gnome desktop. Extra software requirements can be met by the Ubuntu and safe PPA repositories. Scripts may be re-written or added to from time to time, the date serves as the version number. Syntax highlighting on these pages is provided by GVim's "Convert to HTML" option.

Fix Subtitle Offset


#!/bin/bash
# Filename: srt-fix-offset.sh
# Version.: 20052018
# Author..: not robz
# A script to modify subtitle offset beyond the Kodi maximum of 60 seconds.
# Put original titles in a file called "srt.txt" in your home directory and
# run the script.
# In all honesty this is pretty much a copy paste job from Linux Questions.
# For more detailed information goto:
# www.linuxquestions.org/questions/linux-newbie-8/editing-srt-files-4175436550/
#
# Modify and comment the offset variable as appropriate.
# Advance subtitles.
offset="75 seconds"
# Retard subtiles.
#offset="5 seconds ago"

while read start s end; do
    if [[ $start =~ ^..:..:..,... ]]; then
        start=$(date -d "$start $offset" +%H:%M:%S,%N)
        end=$(date -d "$end $offset" +%H:%M:%S,%N)
        echo ${start:0:12} $s ${end:0:12}
    else
        echo $start $s $end
    fi
done < srt.txt >> new-subtitles.srt

No comments: