if( null == progress ) {
progress = MultimediaConversionProgressNull.getSingleton();
}
// Get information about video
VideoInfo videoInfo = null;
{
FFmpeg ffmpeg = new FFmpeg();
videoInfo = ffmpeg.getVideoInfo( inFile );
}
// Check if conversion is required
boolean conversionRequired = false;
if( null == videoInfo.bitRate ) {
conversionRequired = true;
} else if( videoInfo.bitRate.intValue() > 250000 ) {
conversionRequired = true;
}
if( false == "h264".equals( videoInfo.videoCodec ) ) {
conversionRequired = true;
}
if( false == "mpeg4aac".equals( videoInfo.audioCodec ) ) {
conversionRequired = true;
}
// Report length and dimensions
request.setInDurationInSec( videoInfo.durationInSec );
request.setInHeight(videoInfo.height);
request.setInWidth(videoInfo.width);
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);
}
FFmpeg ffmpeg = new FFmpeg(progress);
ffmpeg.convertVideo(videoInfo, outFile);
request.setOutFile(outFile);
request.setConversionPerformed(true);
VideoInfo outVideoInfo = ffmpeg.getVideoInfo( outFile );
request.setOutDurationInSec( outVideoInfo.durationInSec );
request.setOutHeight(outVideoInfo.height);
request.setOutWidth(outVideoInfo.width);
}