Lyrics -> video clip subtitles converter

A note as a piece of memory.
I wanted to suit lyrics to video clip of "Beauty Girls" song performed by Sean Kingston. I downloaded clip, lyrics, and developed a script which with interaction with me, generated subtitle file. It was something about transformation from

your way to beautiful girl
what's why it will never work
you had me suicidal, suicidal
when you say it's over


{410}{514}your way to beautiful girl
{524}{575}that's why it will never work
{586}{691}you had me suicidal, suicidal
{699}{763}when you say it's over

Uh, the script is here:

cat /dev/null > /tmp/sean.txt
T=`date +%s%N`
while true
  LINE=`expr $LINE + 1` LINETEXT=`head -${LINE} $TEXT | tail -1`
  echo $LINETEXT
  TIMES=`date +%s%N`
  TIMEE=`date +%s%N`

  START=`expr $TIMES - $T`
  START=`expr $START / $DIV`

  END=`expr $TIMEE - $T`
  END=`expr $END / $DIV`

  echo "{${START}}{${END}}${LINETEXT}" >> /tmp/sean.txt
exit 0

DIV is a variable to convert nanoseconds produced by date %s%N to frames per second in my particular video clip (26.976 fps).
Run clip and this script at the same moment in nonoverlapping windows. A line of text appears on console. Then press Enter when you hear the dialog/text, and again Enter when you want to clear screen from the text. Every line of text needs two Enters.

Well synchronized subtitles require some training.

No comments: