Class FFMpegWrapper


  • public class FFMpegWrapper
    extends java.lang.Object
    • Constructor Detail

      • FFMpegWrapper

        public FFMpegWrapper​(java.io.File file)
        Creates a wrapper to run ffmpeg for the given video file. Will run ffmpeg in the current working directory of JVM.
        Parameters:
        file - video file to call ffmpeg with
      • FFMpegWrapper

        public FFMpegWrapper​(java.io.File file,
                             java.io.File workingDir)
        Creates a wrapper to run ffmpeg for the given video file. Provide a different workingDir every time you create this FFMpegWrapper as ffmpeg's temp file name in 2-pass encoding is hard coded in the ffmpeg build, which causes problem while running simultaneous multiple encodings. Even you use -passlogfile option, x264_2pass.log file name is hard coded in the older ffmpeg builds. For more details please refer to bug:42346.
        Parameters:
        file - video file to call ffmpeg with
        workingDir - a working directory for ffmpeg; if null, the current working directory of the JVM is used
    • Method Detail

      • getOutputExtension

        public java.lang.String getOutputExtension()
      • setOutputExtension

        public void setOutputExtension​(java.lang.String extension)
      • getFFMpegOutput

        public java.lang.StringBuilder getFFMpegOutput()
      • getProfileName

        public java.lang.String getProfileName()
      • setProfileName

        public void setProfileName​(java.lang.String profileName)
      • getRenditionSelector

        public java.lang.String getRenditionSelector()
      • setRenditionSelector

        public void setRenditionSelector​(java.lang.String renditionSelector)
      • getOutputMimetype

        public java.lang.String getOutputMimetype()
      • setOutputMimetype

        public void setOutputMimetype​(java.lang.String outputMimetype)
      • setTwoPass

        public void setTwoPass()
      • setTwoPass

        public void setTwoPass​(boolean twoPass)
      • setPreset

        public void setPreset​(java.lang.String preset)
      • setAudioSamplingRate

        public void setAudioSamplingRate​(int audioSamplingRate)
      • setAudioBitrate

        public void setAudioBitrate​(int audioBitrate)
      • setVideoCodec

        public void setVideoCodec​(java.lang.String videoCodec)
      • setAudioCodec

        public void setAudioCodec​(java.lang.String audioCodec)
      • setBitrate

        public void setBitrate​(int bitrate)
        Sets the output video bitrate in kbits/second
        Parameters:
        bitrate - The bitrate
      • setInput

        public void setInput​(java.io.File f)
      • setExecutableLocator

        public void setExecutableLocator​(ExecutableLocator locator)
      • setOutputSize

        public void setOutputSize​(java.awt.Dimension dimension)
      • getOutputSize

        public java.awt.Dimension getOutputSize()
      • getInputDuration

        public long getInputDuration()
      • getInputSize

        public java.awt.Dimension getInputSize()
      • getThumbnails

        public java.awt.image.BufferedImage[] getThumbnails​(int thumbnails,
                                                            int start)
        Create thumbnails from the video.
        Parameters:
        thumbnails - The number of desired thumbnails.
        start - The start position in seconds from where to take the first thumbnail.
        Returns:
        The thumbnails.
      • getClip

        public java.io.File getClip​(double startTime,
                                    double endTime,
                                    java.lang.String mimeType)
        Create clip from the video.
        Parameters:
        startTime - startTime of the clip.
        endTime - The end position in seconds of the clip.
        mimeType - Mime type for the clip.
        Returns:
        The thumbnails.
      • join

        public java.io.File join​(java.io.File other,
                                 java.lang.String name)
                          throws java.io.IOException
        Throws:
        java.io.IOException
      • trim

        public java.io.File trim​(java.lang.String name)
                          throws java.io.IOException
        Throws:
        java.io.IOException
      • transcode

        public java.io.File transcode()
                               throws java.io.IOException
        Throws:
        java.io.IOException
      • transcode

        public java.io.File transcode​(java.lang.String extension)
                               throws java.io.IOException
        Throws:
        java.io.IOException
      • setLetterbox

        public void setLetterbox()
      • setLetterbox

        public void setLetterbox​(boolean letterbox)
      • setFitInside

        public void setFitInside()
      • setFitInside

        public void setFitInside​(boolean fitInside)
      • getFilmStrip

        public java.awt.image.BufferedImage getFilmStrip​(int frames,
                                                         int width)
      • setFps

        public void setFps​(java.lang.String fps)
      • setBitrateTolerance

        public void setBitrateTolerance​(int i)
      • setAudioChannels

        public void setAudioChannels​(int i)
      • setCustomFlags

        public void setCustomFlags​(java.lang.String[] flags)
      • setStartTime

        public void setStartTime​(long i)
      • setClipDuration

        public void setClipDuration​(long i)
      • setCropArea

        public void setCropArea​(java.awt.Rectangle rectangle)
      • setInputsize

        public void setInputsize​(java.awt.Dimension inputsize)
      • setDuration

        public void setDuration​(long duration)
      • fromProfile

        public static FFMpegWrapper fromProfile​(java.io.File inputFile,
                                                VideoProfile profile,
                                                java.io.File workingDir)
        Turns a video profile into a FFMpegWrapper.
        Parameters:
        inputFile - property file
        profile - can be the cq:Page or jcr:content node of a profile page
        workingDir - working directory for ffmpeg
        Returns:
        configured FFMpegWrapper