Class Mp4Sanitizer

  • All Implemented Interfaces:

    
    public class Mp4Sanitizer
    
                        

    An MP4 format “sanitizer”.

    Currently the sanitizer always performs the following functions:

    • Return all presentation metadata present in the input as a self-contained contiguous byte array.
    • Find and return a pointer to the span in the input containing the (contiguous) media data.

    “Presentation” metadata means any metadata which is required by an MP4 player to play the file. “Self-contained and contiguous” means that the returned metadata can be concatenated with the media data to form a valid MP4 file.

    The original metadata may or may not need to be modified in order to perform these functions. In the case that the original metadata does not need to be modified, the returned sanitized metadata will be null to prevent needless data copying.

    The sanitizer does not currently support:
    • “Fragmented” MP4 files, which are mostly used for adaptive-bitrate streaming.
    • Discontiguous media data, i.e. media data (mdat) boxes interspersed with presentation metadata (moov).
    • Media data references (dref) pointing to separate files.
    • Any similar format, e.g. Quicktime File Format (mov) or the legacy MP4 version 1, which does not contain the "isom" compatible brand in its file type header (ftyp).
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
      Mp4Sanitizer()
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      static SanitizedMetadata sanitize(InputStream input, long length) Sanitize an MP4 input.
      static SanitizedMetadata sanitizeFileWithCompoundedMdatBoxes(InputStream input, long length, int cumulativeMdatBoxSize) Sanitize an MP4 input featuring multiple MDAT boxes compounded to a single cumulative MDAT box whose byte length needs to be passed down to MP4 sanitizer It's recommended that the given InputStream be capable of skipping, and that it skips fewer bytes than requested only when the end of stream is reached.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Mp4Sanitizer

        Mp4Sanitizer()
    • Method Detail

      • sanitize

         static SanitizedMetadata sanitize(InputStream input, long length)

        Sanitize an MP4 input.

        It's recommended that the given InputStream be capable of skipping, and that it skips fewer bytes than requested only when the end of stream is reached.

        Parameters:
        input - An MP4 format input stream.
        length - The exact length of the input stream.
        Returns:

        The sanitized metadata.

      • sanitizeFileWithCompoundedMdatBoxes

         static SanitizedMetadata sanitizeFileWithCompoundedMdatBoxes(InputStream input, long length, int cumulativeMdatBoxSize)

        Sanitize an MP4 input featuring multiple MDAT boxes compounded to a single cumulative MDAT box whose byte length needs to be passed down to MP4 sanitizer

        It's recommended that the given InputStream be capable of skipping, and that it skips fewer bytes than requested only when the end of stream is reached.

        Parameters:
        input - An MP4 format input stream.
        length - The exact length of the input stream.
        cumulativeMdatBoxSize - The byte length of cumulative, compounded MDAT box
        Returns:

        The sanitized metadata.