Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

19
LINES

< > BotCompany Repo | #1030678 // transformTimestampAccordingToCut

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (3106L/18K).

sS transformTimestampAccordingToCut(S ts, L<DoubleRange> segments) {
  try {
    double time = ffmpeg_parseTimestamp(ts);
    int idx = indexOfPred(segments, r -> r.end > time);
    if (idx >= 0 && idx < l(segments)) {
      double len = 0;
      for i to idx: len += l(segments.get(i));
      DoubleRange seg = segments.get(idx);
      double ofs = time-seg.start;
      double result = len+ofs;
      S formatted = formatHoursMinutesColonSeconds(result);
      printVars_str("transformTimestampAccordingToCut", +ts, +idx, +seg, +ofs, +result, +formatted);
      ret formatted;
    } else
      ret "[cut] " + ts;
  } catch print e {
    ret ts;
  }
}

Author comment

Began life as a copy of #1030676

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt

No comments. add comment

Snippet ID: #1030678
Snippet name: transformTimestampAccordingToCut
Eternal ID of this version: #1030678/7
Text MD5: 8eca8dca416ad3459e6f17df0057d773
Transpilation MD5: 8d96af6ab1290cc110e0ce41e0a0a06a
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-03-03 23:57:49
Source code size: 670 bytes / 19 lines
Pitched / IR pitched: No / No
Views / Downloads: 103 / 161
Version history: 6 change(s)
Referenced in: [show references]