Package com.day.cq.dam.handler.ffmpeg
Class FFMpegWrapper
- java.lang.Object
-
- com.day.cq.dam.handler.ffmpeg.FFMpegWrapper
-
public class FFMpegWrapper extends Object
-
-
Constructor Summary
Constructors Constructor Description FFMpegWrapper(File file)Creates a wrapper to run ffmpeg for the given video file.FFMpegWrapper(File file, File workingDir)Creates a wrapper to run ffmpeg for the given video file.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static FFMpegWrapperfromProfile(File inputFile, VideoProfile profile, File workingDir)Turns a video profile into a FFMpegWrapper.FilegetClip(double startTime, double endTime, String mimeType)Create clip from the video.StringBuildergetFFMpegOutput()BufferedImagegetFilmStrip(int frames, int width)longgetInputDuration()DimensiongetInputSize()StringgetOutputExtension()StringgetOutputMimetype()DimensiongetOutputSize()StringgetProfileName()StringgetRenditionSelector()BufferedImage[]getThumbnails(int thumbnails, int start)Create thumbnails from the video.Filejoin(File other, String name)voidsetAudioBitrate(int audioBitrate)voidsetAudioChannels(int i)voidsetAudioCodec(String audioCodec)voidsetAudioSamplingRate(int audioSamplingRate)voidsetBitrate(int bitrate)Sets the output video bitrate in kbits/secondvoidsetBitrateTolerance(int i)voidsetClipDuration(long i)voidsetCropArea(Rectangle rectangle)voidsetCustomFlags(String[] flags)voidsetDuration(long duration)voidsetExecutableLocator(ExecutableLocator locator)voidsetFitInside()voidsetFitInside(boolean fitInside)voidsetFps(String fps)voidsetInput(File f)voidsetInputsize(Dimension inputsize)voidsetLetterbox()voidsetLetterbox(boolean letterbox)voidsetOutputExtension(String extension)voidsetOutputMimetype(String outputMimetype)voidsetOutputSize(Dimension dimension)voidsetPreset(String preset)voidsetProfileName(String profileName)voidsetRenditionSelector(String renditionSelector)voidsetStartTime(long i)voidsetTwoPass()voidsetTwoPass(boolean twoPass)voidsetVideoCodec(String videoCodec)Filetranscode()Filetranscode(String extension)Filetrim(String name)
-
-
-
Constructor Detail
-
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 thisFFMpegWrapperas 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 withworkingDir- a working directory for ffmpeg; ifnull, the current working directory of the JVM is used
-
-
Method Detail
-
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 fileprofile- can be the cq:Page or jcr:content node of a profile pageworkingDir- working directory for ffmpeg- Returns:
- configured FFMpegWrapper
-
-