getFfmpegTimestamp static method

String getFfmpegTimestamp(
  1. Duration duration
)

Used for generating a timestamp for use with FFMPEG.

Implementation

static String getFfmpegTimestamp(Duration duration) {
  String twoDigits(int n) => n.toString().padLeft(2, '0');
  String threeDigits(int n) => n.toString().padLeft(3, '0');

  String hours = twoDigits(duration.inHours);
  String mins = twoDigits(duration.inMinutes.remainder(60));
  String secs = twoDigits(duration.inSeconds.remainder(60));
  String mills = threeDigits(duration.inMilliseconds.remainder(1000));

  return '$hours:$mins:$secs.$mills';
}