Skip to content

Instantly share code, notes, and snippets.

@ara4n
Created September 9, 2018 22:26
Show Gist options
  • Save ara4n/71df14d9112ac8c94613ae56bedc3e07 to your computer and use it in GitHub Desktop.
Save ara4n/71df14d9112ac8c94613ae56bedc3e07 to your computer and use it in GitHub Desktop.
Shifting subtitle timings
# Moving subtitles 4 seconds into the future:
cat subs.txt | perl -ne 'sub fix { $t=$_[0]*60*1000 + $_[1]*1000 + $_[2]; $t+=4000; return sprintf("%02d:%02d.%03d", int($t/(60*1000)), int($t/1000) % 60, $t % 1000); } if (/^0:(..):(..).(...),0:(..):(..).(...)$/) { $a=fix($1,$2,$3); $b=fix($4,$5,$6); print "0:$a,0:$b\n" } else { print $_ }' > subs2.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment