previewFrameOffset function

Duration previewFrameOffset(
  1. String value,
  2. double frameRate
)

value as a position in the video, given the rate its frames run at.

Implementation

Duration previewFrameOffset(String value, double frameRate) {
  final match = _timeCode.firstMatch(value)!;
  final frames = int.parse(match.group(4)!);
  return Duration(
        hours: int.parse(match.group(1)!),
        minutes: int.parse(match.group(2)!),
        seconds: int.parse(match.group(3)!),
      ) +
      Duration(microseconds: (frames * 1000000 / frameRate).round());
}