Class MediaInfo

All Implemented Interfaces:
AutoCloseable

public class MediaInfo extends MediaInfoBase<MediaInfo>
The default optional class to access media file attributes without the need to define a customized class that extends MediaInfoBase. Example usage:
 MediaInfoLibrary library = MediaInfoLibrary.newInstance();
 MediaInfoAccessor accessor = new MediaInfoAccessor(library);
 try (MediaInfo myVideo = new MediaInfo(accessor).open("./MyVideo.mkv")) {
     List videoCodecs = MediaInfo.parseList(myVideo.get(StreamType.General, 0, "Video_Codec_List"));
     int videoWidth = Integer.parseInt(myVideo.get(StreamType.Video, 0, "Width"));

     // Get and parse additional parameters...
 }
 
See Also:
  • Constructor Details

    • MediaInfo

      public MediaInfo(MediaInfoAccessor accessor)
      Creates a new MediaInfo object.
      Parameters:
      accessor - the accessor used to call the underling libMediaInfo library.
  • Method Details

    • inform

      public String inform()
      Get all details about a file.
      Returns:
      All details about a file in one string
    • get

      public String get(StreamType streamType, int streamNumber, String parameter)
      Get a piece of information about a file (parameter is a string).
      Parameters:
      streamType - the stream type
      streamNumber - the stream number
      parameter - the parameter you are looking for in the stream (e.g., resolution, codec, bitrate, etc.)
      Returns:
      the query result, or empty if there is a problem or not found
      See Also:
    • get

      public String get(StreamType streamType, int streamNumber, String parameter, InfoType infoType)
      Get a piece of information about a file (parameter is a string).
      Parameters:
      streamType - the stream type
      streamNumber - the stream number
      parameter - the parameter you are looking for in the stream (e.g., resolution, codec, bitrate, etc.)
      infoType - the type of information about the parameter
      See Also:
    • get

      public String get(StreamType streamType, int streamNumber, String parameter, InfoType infoType, InfoType searchType)
      Get a piece of information about a file (parameter is a string). For a list of available parameters, please refer to General.csv.
      Parameters:
      streamType - the stream type
      streamNumber - the stream number
      parameter - the parameter you are looking for in the stream (e.g., resolution, codec, bitrate, etc.)
      infoType - the type of information about the parameter
      searchType - describes where to look for the parameter
      Returns:
      the queries information; or an empty string if there was a problem
    • get

      public String get(StreamType streamType, int streamNumber, int parameterIndex)
      Get a piece of information about a file (parameter is an integer that represents the parameter index).
      Parameters:
      streamType - the stream type
      streamNumber - the stream number
      parameterIndex - the parameter index that you are looking for in the stream
      Returns:
      a string about information you search, an empty string if there is a problem
    • get

      public String get(StreamType streamType, int streamNumber, int parameterIndex, InfoType infoType)
      Get a piece of information about a file (parameter is an integer that represents the parameter index).
      Parameters:
      streamType - the stream type
      streamNumber - the stream number
      parameterIndex - the parameter index that you are looking for in the stream
      infoType - the type of information you want about the parameter (the text, the measure, the help...)
      Returns:
      the information or an empty string if there is a problem
    • getStreamCount

      public int getStreamCount(StreamType streamType)
      Gets the number of streams for the given stream type.
      Parameters:
      streamType - the stream type
      Returns:
      number of streams of the given stream type
    • getStreamOrParameterCount

      public int getStreamOrParameterCount(StreamType streamType, int streamNumber)
      Gets the number of streams for the given stream type or the total count of information parameters for a stream.
      Parameters:
      streamType - the stream type
      streamNumber - the stream number
      Returns:
      number of streams of the given stream type
    • getOption

      public String getOption(String option)
      Gets information about MediaInfo.
      Parameters:
      option - The name of option
      Returns:
      the option value
    • setOption

      public String setOption(String option, String value)
      Configures information about MediaInfo.
      Parameters:
      option - The name of option
      value - The value of option
      Returns:
      "" means no; else, any other value means yes