}
// Get information about video
FFmpegMediaInfo videoInfo = null;
{
FFmpegProcessor ffmpeg = FFmpeg.getProcessor(null);
videoInfo = ffmpeg.getMediaInfo( inFile );
}
// Check if conversion is required
boolean conversionRequired = videoConversionThreshold.isConversionRequired(
videoInfo.getVideoCodec()
,videoInfo.getBitRate()
,videoInfo.getAudioCodec()
,videoInfo.getBitRate()
,videoInfo.getWidth()
,videoInfo.getHeight()
);
// Report length and dimensions
request.setInDurationInSec( videoInfo.getDurationInSec() );
request.setInHeight(videoInfo.getHeight().intValue());
request.setInWidth(videoInfo.getWidth().intValue());
if( false == conversionRequired ) {
// Conversion not required, converted file is the uploaded file
request.setOutFile(inFile);
progress.updateProgress(100);
} else {
File outFile = request.getOutFile();
if( null == outFile ) {
File parentDir = inFile.getParentFile();
outFile = File.createTempFile("conv", ".mp4", parentDir);
}
FFmpegProcessor ffmpeg = FFmpeg.getProcessor(progress);
ffmpeg.convertVideo(videoInfo, outFile);
request.setOutFile(outFile);
request.setConversionPerformed(true);
FFmpegMediaInfo outVideoInfo = ffmpeg.getMediaInfo( outFile );
if( null == outVideoInfo.getDurationInSec() ) {
request.setOutDurationInSec( (float)0.0 );
} else {
request.setOutDurationInSec( outVideoInfo.getDurationInSec() );
request.setOutHeight(outVideoInfo.getHeight().intValue());
request.setOutWidth(outVideoInfo.getWidth().intValue());
}
}
// Create thumbnail
if( request.isThumbnailRequested() ){
File thumbnailFile = request.getThumbnailFile();
if( null == thumbnailFile ) {
File parentDir = inFile.getParentFile();
String name = inFile.getName();
int index = name.lastIndexOf('.');
if( index > 0 ) {
name = name.substring(0, index);
}
name = name+"_thumb.jpeg";
thumbnailFile = new File(parentDir, name);
}
FFmpegProcessor ffmpeg = FFmpeg.getProcessor(null);
ffmpeg.createThumbnail(videoInfo, thumbnailFile, VIDEO_THUMB_WIDTH, VIDEO_THUMB_HEIGHT);
request.setThumbnailFile(thumbnailFile);
request.setThumbnailCreated(true);
ImageMagickInfo imInfo = ImageMagick.getInfo();