#!/bin/bash

awk -F= -v duration=$((45 * 60)) '
    function chapter(start, end, title) {
    print "[CHAPTER]"
    print "TIMEBASE=1/1000"
    print "START=" start "000"
    print "END=" end "000"
    print "title=" title }
  BEGIN { print ";FFMETADATA1" }
    { split($1, hms, ":") ;
      end=3600 * hms[1] + 60 * hms[2] + hms[3] }
title { chapter(start, end, title) }
    { start=end; title=$2 }
END { chapter(start, duration, title) }'