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 = false;
if( null == videoInfo.getBitRate() ) {
conversionRequired = true;
} else if( videoInfo.getBitRate().intValue() > 250000 ) {
conversionRequired = true;
}
if( false == "h264".equals( videoInfo.getVideoCodec() ) ) {
conversionRequired = true;
}
if( false == "mpeg4aac".equals( videoInfo.getAudioCodec() ) ) {
conversionRequired = true;
}
// Report length and dimensions
request.setInDurationInSec( videoInfo.getDurationInSec() );
request.setInHeight(videoInfo.getHeight());
request.setInWidth(videoInfo.getWidth());
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());
request.setOutWidth(outVideoInfo.getWidth());
}
// Create thumbnail
if( request.isThumbnailRequested() ){
File thumbnailFile = request.getThumbnailFile();