Class FFmpegUtils

java.lang.Object
net.bramp.ffmpeg.FFmpegUtils

public final class FFmpegUtils extends Object
Helper class with commonly used methods.
  • Method Details

    • millisecondsToString

      @Deprecated @InlineMe(replacement="FFmpegUtils.toTimecode(milliseconds, MILLISECONDS)", imports="net.bramp.ffmpeg.FFmpegUtils", staticImports="java.util.concurrent.TimeUnit.MILLISECONDS") public static String millisecondsToString(long milliseconds)
      Deprecated.
      please use #toTimecode() instead.
      Convert milliseconds to "hh:mm:ss.ms" String representation.
      Parameters:
      milliseconds - time duration in milliseconds
      Returns:
      time duration in human-readable format
    • toTimecode

      public static String toTimecode(long duration, TimeUnit units)
      Convert the duration to "hh:mm:ss" timecode representation, where ss (seconds) can be decimal.
      Parameters:
      duration - the duration.
      units - the unit the duration is in.
      Returns:
      the timecode representation.
    • millisToSeconds

      public static String millisToSeconds(long millis)
      Converts milliseconds to a seconds string representation. Uses integer format when there are no fractional seconds, otherwise uses decimal format with up to 3 decimal places and trailing zeros removed.
      Parameters:
      millis - duration in milliseconds
      Returns:
      seconds as a string (e.g. "5", "0.005", "1.5")
    • fromTimecode

      public static long fromTimecode(String time)
      Returns the number of nanoseconds this timecode represents. The string is expected to be in the format "hour:minute:second", where second can be a decimal number.
      Parameters:
      time - the timecode to parse.
      Returns:
      the number of nanoseconds or -1 if time is 'N/A'
    • parseBitrate

      public static long parseBitrate(String bitrate)
      Converts a string representation of bitrate to a long of bits per second.
      Parameters:
      bitrate - in the form of 12.3kbits/s
      Returns:
      the bitrate in bits per second or -1 if bitrate is 'N/A'