if( null == progress ) {
progress = MultimediaConversionProgressNull.getSingleton();
}
// 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();