Package com.day.cq.dam.handler.ffmpeg
Class FFMpegWrapper
- java.lang.Object
-
- com.day.cq.dam.handler.ffmpeg.FFMpegWrapper
-
public class FFMpegWrapper extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description FFMpegWrapper(java.io.File file)
Creates a wrapper to run ffmpeg for the given video file.FFMpegWrapper(java.io.File file, java.io.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 FFMpegWrapper
fromProfile(java.io.File inputFile, VideoProfile profile, java.io.File workingDir)
Turns a video profile into a FFMpegWrapper.java.io.File
getClip(double startTime, double endTime, java.lang.String mimeType)
Create clip from the video.java.lang.StringBuilder
getFFMpegOutput()
java.awt.image.BufferedImage
getFilmStrip(int frames, int width)
long
getInputDuration()
java.awt.Dimension
getInputSize()
java.lang.String
getOutputExtension()
java.lang.String
getOutputMimetype()
java.awt.Dimension
getOutputSize()
java.lang.String
getProfileName()
java.lang.String
getRenditionSelector()
java.awt.image.BufferedImage[]
getThumbnails(int thumbnails, int start)
Create thumbnails from the video.java.io.File
join(java.io.File other, java.lang.String name)
void
setAudioBitrate(int audioBitrate)
void
setAudioChannels(int i)
void
setAudioCodec(java.lang.String audioCodec)
void
setAudioSamplingRate(int audioSamplingRate)
void
setBitrate(int bitrate)
Sets the output video bitrate in kbits/secondvoid
setBitrateTolerance(int i)
void
setClipDuration(long i)
void
setCropArea(java.awt.Rectangle rectangle)
void
setCustomFlags(java.lang.String[] flags)
void
setDuration(long duration)
void
setExecutableLocator(ExecutableLocator locator)
void
setFitInside()
void
setFitInside(boolean fitInside)
void
setFps(java.lang.String fps)
void
setInput(java.io.File f)
void
setInputsize(java.awt.Dimension inputsize)
void
setLetterbox()
void
setLetterbox(boolean letterbox)
void
setOutputExtension(java.lang.String extension)
void
setOutputMimetype(java.lang.String outputMimetype)
void
setOutputSize(java.awt.Dimension dimension)
void
setPreset(java.lang.String preset)
void
setProfileName(java.lang.String profileName)
void
setRenditionSelector(java.lang.String renditionSelector)
void
setStartTime(long i)
void
setTwoPass()
void
setTwoPass(boolean twoPass)
void
setVideoCodec(java.lang.String videoCodec)
java.io.File
transcode()
java.io.File
transcode(java.lang.String extension)
java.io.File
trim(java.lang.String name)
-
-
-
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 thisFFMpegWrapper
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 withworkingDir
- a working directory for ffmpeg; ifnull
, 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 fileprofile
- can be the cq:Page or jcr:content node of a profile pageworkingDir
- working directory for ffmpeg- Returns:
- configured FFMpegWrapper
-
-