Class Mp4DurationReader

java.lang.Object
org.exoplatform.webconferencing.util.Mp4DurationReader

public final class Mp4DurationReader extends Object
Reads how long an MP4 recording lasts from its movie header (mvhd, inside moov), without decoding it and without ffmpeg.

The top-level boxes are walked by seeking over them, so a moov written after the media data, as the recorder writes it, costs a few reads whatever the size of the file. Anything that is not a readable, non-fragmented MP4 has no duration.

  • Method Details

    • readSeconds

      public static Long readSeconds(String location)
      Reads the duration of an MP4 file.
      Parameters:
      location - the path of the file
      Returns:
      the duration in seconds, rounded to the nearest second, or null when the file is not a readable MP4 or does not tell its duration (a fragmented MP4 says 0)