Class ScreenExtractor


  • public class ScreenExtractor
    extends java.lang.Object
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private ProcessLocator locator
      The locator of the ffmpeg executable used by this extractor.
      private static org.slf4j.Logger LOG  
      private int numberOfScreens  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getNumberOfScreens()  
      void render​(MultimediaObject multimediaObject, int width, int height, int seconds, java.io.File outputDir, int quality)
      Generate a single screenshot from source video.
      void render​(MultimediaObject multimediaObject, int width, int height, int seconds, java.io.File outputDir, java.lang.String fileNamePrefix, java.lang.String extension, int quality)
      Generates screenshots from source video.
      void renderOneImage​(MultimediaObject multimediaObject, int width, int height, long millis, java.io.File outputFile, int quality)
      Generate exactly one screenshot from source video
      void renderOneImage​(MultimediaObject multimediaObject, int width, int height, long millis, java.io.File outputFile, int quality, boolean keyframesSeeking)
      Generate exactly one screenshot from source video using given seeking mode.
      • Methods inherited from class java.lang.Object

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

      • LOG

        private static final org.slf4j.Logger LOG
      • locator

        private final ProcessLocator locator
        The locator of the ffmpeg executable used by this extractor.
      • numberOfScreens

        private int numberOfScreens
    • Constructor Detail

      • ScreenExtractor

        public ScreenExtractor()
        It builds an extractor using a FFMPEGProcess instance to locate the ffmpeg executable to use.
      • ScreenExtractor

        public ScreenExtractor​(ProcessLocator locator)
        It builds an extractor with a custom FFMPEGProcess.
        Parameters:
        locator - The locator picking up the ffmpeg executable used by the extractor.
    • Method Detail

      • getNumberOfScreens

        public int getNumberOfScreens()
        Returns:
        The number of screens found
      • render

        public void render​(MultimediaObject multimediaObject,
                           int width,
                           int height,
                           int seconds,
                           java.io.File outputDir,
                           java.lang.String fileNamePrefix,
                           java.lang.String extension,
                           int quality)
                    throws InputFormatException,
                           EncoderException
        Generates screenshots from source video.
        Parameters:
        multimediaObject - Source MultimediaObject @see MultimediaObject
        width - Output width, pass -1 to use video width and height
        height - Output height (Ignored when width = -1)
        seconds - Interval in seconds between screens
        outputDir - Destination of output images
        fileNamePrefix - Name all thumbnails will start with
        extension - Image extension for output (jpg, png, etc)
        quality - The range is between 1-31 with 31 being the worst quality
        Throws:
        InputFormatException - If the source multimedia file cannot be decoded.
        EncoderException - If a problems occurs during the encoding process.
      • render

        public void render​(MultimediaObject multimediaObject,
                           int width,
                           int height,
                           int seconds,
                           java.io.File outputDir,
                           int quality)
                    throws EncoderException
        Generate a single screenshot from source video.
        Parameters:
        multimediaObject - Source MultimediaObject @see MultimediaObject
        width - Output width, pass -1 to use video width and height
        height - Output height (Ignored when width = -1)
        seconds - Interval in seconds between screens
        outputDir - Destination folder of output image
        quality - The range is between 1-31 with 31 being the worst quality
        Throws:
        InputFormatException - If the source multimedia file cannot be decoded.
        EncoderException - If a problems occurs during the encoding process.
      • renderOneImage

        public void renderOneImage​(MultimediaObject multimediaObject,
                                   int width,
                                   int height,
                                   long millis,
                                   java.io.File outputFile,
                                   int quality)
                            throws InputFormatException,
                                   EncoderException
        Generate exactly one screenshot from source video
        Parameters:
        multimediaObject - Source MultimediaObject @see MultimediaObject
        width - Output width, pass -1 to use video width and height
        height - Output height (Ignored when width = -1)
        millis - At which second in the video should the screenshot be made
        outputFile - Outputfile
        quality - The range is between 1-31 with 31 being the worst quality
        Throws:
        InputFormatException - If the source multimedia file cannot be decoded.
        EncoderException - If a problems occurs during the encoding process.
      • renderOneImage

        public void renderOneImage​(MultimediaObject multimediaObject,
                                   int width,
                                   int height,
                                   long millis,
                                   java.io.File outputFile,
                                   int quality,
                                   boolean keyframesSeeking)
                            throws InputFormatException,
                                   EncoderException
        Generate exactly one screenshot from source video using given seeking mode.
        Parameters:
        multimediaObject - Source MultimediaObject @see MultimediaObject
        width - Output width, pass -1 to use video width and height
        height - Output height (Ignored when width = -1)
        millis - At which second in the video should the screenshot be made
        outputFile - Outputfile
        quality - The range is between 1-31 with 31 being the worst quality
        keyframesSeeking - If True, it forces FFmpeg to parse an input file using keyframes, which is very fast. If False, input will be parsed frame by frame. See FFmpeg Wiki: Seeking
        Throws:
        InputFormatException - If the source multimedia file cannot be decoded.
        EncoderException - If a problems occurs during the encoding process.