Class FFMpegWrapper

java.lang.Object
com.day.cq.dam.handler.ffmpeg.FFMpegWrapper

public class FFMpegWrapper extends Object
  • Constructor Details

    • FFMpegWrapper

      public FFMpegWrapper(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(File file, 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 Details

    • getOutputExtension

      public String getOutputExtension()
    • setOutputExtension

      public void setOutputExtension(String extension)
    • getFFMpegOutput

      public StringBuilder getFFMpegOutput()
    • getProfileName

      public String getProfileName()
    • setProfileName

      public void setProfileName(String profileName)
    • getRenditionSelector

      public String getRenditionSelector()
    • setRenditionSelector

      public void setRenditionSelector(String renditionSelector)
    • getOutputMimetype

      public String getOutputMimetype()
    • setOutputMimetype

      public void setOutputMimetype(String outputMimetype)
    • setTwoPass

      public void setTwoPass()
    • setTwoPass

      public void setTwoPass(boolean twoPass)
    • setPreset

      public void setPreset(String preset)
    • setAudioSamplingRate

      public void setAudioSamplingRate(int audioSamplingRate)
    • setAudioBitrate

      public void setAudioBitrate(int audioBitrate)
    • setVideoCodec

      public void setVideoCodec(String videoCodec)
    • setAudioCodec

      public void setAudioCodec(String audioCodec)
    • setBitrate

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

      public void setInput(File f)
    • setExecutableLocator

      public void setExecutableLocator(ExecutableLocator locator)
    • setOutputSize

      public void setOutputSize(Dimension dimension)
    • getOutputSize

      public Dimension getOutputSize()
    • getInputDuration

      public long getInputDuration()
    • getInputSize

      public Dimension getInputSize()
    • getThumbnails

      public 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 File getClip(double startTime, double endTime, 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 File join(File other, String name) throws IOException
      Throws:
      IOException
    • trim

      public File trim(String name) throws IOException
      Throws:
      IOException
    • transcode

      public File transcode() throws IOException
      Throws:
      IOException
    • transcode

      public File transcode(String extension) throws IOException
      Throws:
      IOException
    • setLetterbox

      public void setLetterbox()
    • setLetterbox

      public void setLetterbox(boolean letterbox)
    • setFitInside

      public void setFitInside()
    • setFitInside

      public void setFitInside(boolean fitInside)
    • getFilmStrip

      public BufferedImage getFilmStrip(int frames, int width)
    • setFps

      public void setFps(String fps)
    • setBitrateTolerance

      public void setBitrateTolerance(int i)
    • setAudioChannels

      public void setAudioChannels(int i)
    • setCustomFlags

      public void setCustomFlags(String[] flags)
    • setStartTime

      public void setStartTime(long i)
    • setClipDuration

      public void setClipDuration(long i)
    • setCropArea

      public void setCropArea(Rectangle rectangle)
    • setInputsize

      public void setInputsize(Dimension inputsize)
    • setDuration

      public void setDuration(long duration)
    • fromProfile

      public static FFMpegWrapper fromProfile(File inputFile, VideoProfile profile, 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