Class FFprobe

java.lang.Object
com.github.kokorin.jaffree.ffprobe.FFprobe

public class FFprobe extends Object
FFprobe provides an ability to execute ffprobe process.
  • Constructor Details

    • FFprobe

      public FFprobe(Path executable)
      Creates FFprobe.
      Parameters:
      executable - path to ffprobe binary
  • Method Details

    • addArgument

      public FFprobe addArgument(String argument)
      Adds custom argument to ffprobe arguments list.

      Note: if value contains spaces it should not be wrapped with quotes. Also spaces should not be escaped with backslash

      Parameters:
      argument - argument
      Returns:
      this
    • addArguments

      public FFprobe addArguments(String key, String value)
      Adds custom arguments to ffprobe arguments list.

      Note: if value contains spaces it should not be wrapped with quotes. Also spaces should not be escaped with backslash

      Parameters:
      key - key argument
      value - value argument
      Returns:
      this
    • setSelectStreams

      public FFprobe setSelectStreams(String streamSpecifier)
      Select only the streams specified by stream_specifier.

      This option affects only the options related to streams (e.g. show_streams, show_packets, etc.).

      Parameters:
      streamSpecifier - stream specifier
      Returns:
      this
      See Also:
    • setSelectStreams

      public FFprobe setSelectStreams(StreamType streamType)
      Select only the streams of the specified type.
      Parameters:
      streamType - stream type
      Returns:
      this
    • setShowData

      public FFprobe setShowData(boolean showData)
      Show payload data, as a hexadecimal and ASCII dump.

      Coupled with -show_packets, it will dump the packets’ data.

      Coupled with -show_streams, it will dump the codec extradata.

      Parameters:
      showData - true to show data
      Returns:
      this
    • setShowPrivateData

      public FFprobe setShowPrivateData(boolean showPrivateData)
      Show private data, that is data depending on the format of the particular shown element. This option is enabled by default, but you may need to disable it for specific uses.
      Parameters:
      showPrivateData - true to show private data
      Returns:
      this
    • setShowDataHash

      public FFprobe setShowDataHash(String algorithm)
      Show a hash of payload data, for packets with -show_packets and for codec extradata with -show_streams.
      Parameters:
      algorithm - algorithm to calculate hash
      Returns:
      this
    • setShowFormat

      public FFprobe setShowFormat(boolean showFormat)
      Show information about the container format of the input multimedia stream.
      Parameters:
      showFormat - true to show format
      Returns:
      this
    • setShowEntries

      public FFprobe setShowEntries(String showEntries)
      Set list of entries to show.

      Entries are specified according to the following syntax. section_entries contains a list of section entries separated by :. Each section entry is composed by a section name (or unique name), optionally followed by a list of entries local to that section, separated by ,.

      Note that the order of specification of the local section entries is not honored in the output, and the usual display order will be retained.

      The formal syntax is given by:

      LOCAL_SECTION_ENTRIES ::= SECTION_ENTRY_NAME[,LOCAL_SECTION_ENTRIES]

      SECTION_ENTRY ::= SECTION_NAME[=[LOCAL_SECTION_ENTRIES]]

      SECTION_ENTRIES ::= SECTION_ENTRY[:SECTION_ENTRIES]

      Note: this option overwrites any "show..." set before, so this method should not be used together with any of setShowFormat(boolean), setShowFrames(boolean), setShowPackets(boolean), setShowStreams(boolean), setShowChapters(boolean) or setShowPrograms(boolean)

      Parameters:
      showEntries - list entries syntax
      Returns:
      this
    • setShowPackets

      public FFprobe setShowPackets(boolean showPackets)
      Show information about each packet contained in the input multimedia stream.

      Requires -show_streams

      Parameters:
      showPackets - true to show packets
      Returns:
      this
      See Also:
    • setShowFrames

      public FFprobe setShowFrames(boolean showFrames)
      Show information about each frame and subtitle contained in the input multimedia stream.
      Parameters:
      showFrames - true to show frames
      Returns:
      this
    • setShowLog

      public FFprobe setShowLog(LogLevel showLog)
      Show logging information from the decoder about each frame according to the value set in loglevel, (see -loglevel).

      This option requires -show_frames.

      Parameters:
      showLog - decoder log level
      Returns:
      this
      See Also:
    • setShowStreams

      public FFprobe setShowStreams(boolean showStreams)
      Show information about each media stream contained in the input multimedia stream.
      Parameters:
      showStreams - true to show streams
      Returns:
      this
    • setShowPrograms

      public FFprobe setShowPrograms(boolean showPrograms)
      Show information about programs and their streams contained in the input multimedia stream.
      Parameters:
      showPrograms - true to show programs
      Returns:
      this
    • setShowChapters

      public FFprobe setShowChapters(boolean showChapters)
      Show information about chapters stored in the format.
      Parameters:
      showChapters - true to show chapters
      Returns:
      this
    • setCountFrames

      public FFprobe setCountFrames(boolean countFrames)
      Count the number of frames per stream and report it in the corresponding stream section.

      Requires -show_streams

      Parameters:
      countFrames - true to count frames
      Returns:
      this
      See Also:
    • setCountPackets

      public FFprobe setCountPackets(boolean countPackets)
      Count the number of packets per stream and report it in the corresponding stream section.

      Requires -show_streams

      Parameters:
      countPackets - true to count packets
      Returns:
      this
    • setReadIntervals

      public FFprobe setReadIntervals(String intervals)
      Read only the specified intervals. read_intervals must be a sequence of interval specifications separated by ",".

      ffprobe will seek to the interval starting point, and will continue reading from that.

      The formal syntax is given by:

      INTERVAL ::= [START|+START_OFFSET][%[END|+END_OFFSET|+#NUMBER_OF_FRAMES]]

      INTERVALS ::= INTERVAL[,INTERVALS]

      Parameters:
      intervals - interval specification
      Returns:
      this
    • setProbeSize

      public FFprobe setProbeSize(Long probeSize)
      Set probing size (from 32 to I64_MAX) (default 5e+006).
      Parameters:
      probeSize - prpobe size in bytes
      Returns:
      this
    • setAnalyzeDuration

      public FFprobe setAnalyzeDuration(Long analyzeDurationMicros)
      Specify how many microseconds are analyzed to probe the input (from 0 to I64_MAX). (default 0).
      Parameters:
      analyzeDurationMicros - analyze duration micros
      Returns:
      this
    • setAnalyzeDuration

      public FFprobe setAnalyzeDuration(Number analyzeDurationInTimeUnit, TimeUnit timeUnit)
      Specify how long to analyze to probe the input (from 0 to I64_MAX) (default 0).
      Parameters:
      analyzeDurationInTimeUnit - duration
      timeUnit - time unit
      Returns:
      this
    • setFpsProbeSize

      public FFprobe setFpsProbeSize(Long fpsProbeSize)
      Number of frames used to probe fps (from -1 to 2.14748e+009) (default -1).
      Parameters:
      fpsProbeSize - frames
      Returns:
      this
    • setFormat

      public FFprobe setFormat(String format)
      Force input file format. The format is normally auto detected for input files, so this option is not needed in most cases.
      Parameters:
      format - format
      Returns:
      this
    • setInput

      public FFprobe setInput(Path inputPath)
      Sets input to analyze with ffprobe.
      Parameters:
      inputPath - path to media file
      Returns:
      this
    • setInput

      public FFprobe setInput(String inputUriOrPath)
      Sets input to analyze with ffprobe.
      Parameters:
      inputUriOrPath - URI or path to media file
      Returns:
      this
    • setInput

      public FFprobe setInput(InputStream inputStream)
      Sets input to analyze with ffprobe.
      Parameters:
      inputStream - input stream to analyze
      Returns:
      this
    • setInput

      public FFprobe setInput(InputStream inputStream, int bufferSize)
      Sets input to analyze with ffprobe.
      Parameters:
      inputStream - input stream to analyze
      bufferSize - buffer size to copy bytes from input stream
      Returns:
      this
    • setInput

      public FFprobe setInput(SeekableByteChannel inputChannel)
      Sets input to analyze with ffprobe.
      Parameters:
      inputChannel - byte channel to analyze
      Returns:
      this
    • setInput

      public FFprobe setInput(SeekableByteChannel inputChannel, int bufferSize)
      Sets input to analyze with ffprobe.
      Parameters:
      inputChannel - byte channel to analyze
      bufferSize - buffer size to copy bytes from input stream
      Returns:
      this
    • setInput

      public FFprobe setInput(Input input)
      Sets input to analyze with ffprobe.
      Parameters:
      input - input to analyze
      Returns:
      this
    • setFormatParser

      public FFprobe setFormatParser(FormatParser formatParser)
      Sets ffprobe output format parser (and corresponding output format).

      JsonFormatParser is used by default. It's possible to provide custom implementation.

      Parameters:
      formatParser - format parser
      Returns:
      this
    • setLogLevel

      public FFprobe setLogLevel(LogLevel logLevel)
      Sets ffprobe logging level.

      Note: for message to appear in SLF4J logging it's required to configure appropriate log level for SLF4J.

      Parameters:
      logLevel - log level
      Returns:
      this
    • executeAsync

      public Future<FFprobeResult> executeAsync()
      Starts asynchronous ffprobe execution.
      Returns:
      ffprobe result future
    • execute

      public FFprobeResult execute()
      Starts synchronous ffprobe execution.

      Current thread is blocked until ffprobe is finished.

      Returns:
      ffprobe result
    • buildArguments

      protected List<String> buildArguments()
      Constructs ffprobe command line.
      Returns:
      arguments list
    • createStdOutReader

      protected StdReader<FFprobeResult> createStdOutReader(FormatParser formatParser)
      Creates StdReader which is used to read ffprobe stdout.

      Note: default implementation uses FormatParser to parse output.

      Parameters:
      formatParser - format parser to use
      Returns:
      this
    • createStdErrReader

      protected StdReader<FFprobeResult> createStdErrReader()
      Creates StdReader which is used to read ffprobe stderr.

      Note: default implementation simply logs everything with SLF4J.

      Returns:
      this
    • atPath

      public static FFprobe atPath()
      Creates FFprobe.

      Note: directory with ffprobe binaries must be in PATH environment variable.

      Returns:
      FFprobe
    • atPath

      public static FFprobe atPath(Path pathToDir)
      Creates FFprobe.
      Parameters:
      pathToDir - path to ffprobe directory
      Returns:
      FFprobe