Home Forums Tips & Techniques SRC generator from Markers

Tagged: 

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #1841
    Cristian Vogel
    Participant

      I was working on a video edit, and came up with a Smalltalk script for Kyma that can export markers and marker times to SRT format, for further editing and importing into software like DaVinci Resolve as subtitles.  Maybe its useful for someone at some point…

       

      | times r count s s2 m m2 stream formatted sf padding padding2 padding3 padding4 |

      sf := ‘CristianVogel_vs_Myceliyum_BirdsAreGettingLouderMasterMix_1632-01-CUES.wav’.

      stream := ‘/Users/cristianvogel/AUDIO DATA/Birds are getting louder/KymaOutput.srt’ asFilename writeStream.

      count := 0.
      padding :=”. padding2 :=”. padding3 := ”. padding4 := ”.
      m := -1. m2 := 0.

      times := sf asSamplesFile markersToTimes.

      formatted := times collect: [:i |

      count := count + 1.
      s := (i roundTo: 1) removeUnits mod: 60.
      s2 := (s + 3) mod: 60.
      (s = 0) ifTrue: [ m:=m+1 ].
      (s2 = 0) ifTrue: [ m2 := m2 + 1].

      (s < 10) ifTrue: [ padding := ‘0’] ifFalse: [ padding := ” ].
      (m < 10) ifTrue: [ padding2 := ‘0’] ifFalse: [ padding2 := ” ].
      (m2 < 10) ifTrue: [ padding3 := ‘0’] ifFalse: [ padding3 := ” ].
      (s2 < 10) ifTrue: [ padding4 := ‘0’] ifFalse: [ padding4 := ” ].

      r := ‘\’& count &’\’&’01:’&padding2&m&’:’ &padding&s
      &’,000 –> ‘
      &’01:’&padding3&m2&’:’ &padding4&s2&’,000\’&’ \’.

      r withCRs
      ].

      stream nextPutAll: formatted printString.
      stream flush.
      stream close.

      A valid SRT file looks like this…

      1
      01:01:01,000 –> 01:01:03,000
      Text

      2
      01:01:04,000 –> 01:01:06,000
      Text

      3
      01:01:07,000 –> 01:01:09,000
      Text

      4
      01:01:10,000 –> 01:01:12,000
      Text

      5
      01:01:13,000 –> 01:01:15,000
      Text

    Viewing 1 post (of 1 total)
    • You must be logged in to reply to this topic.