// // general information about this file // ================================================================================================================= private int internalGetType() { Stream videoStream = getStream(CODEC_TYPE_VIDEO); if (videoStream == null) return TYPE_NO_GOOD; Stream audioStream = getStream(CODEC_TYPE_AUDIO); if (audioStream == null) return TYPE_NO_GOOD; // good video codec and profile if (VIDEO_CODEC.equals(videoStream.getCodec_name()) && VIDEO_PROFILE.equals(videoStream.getProfile())) { // good audio codec if (AUDIO_CODEC_1.equals(audioStream.getCodec_name()) || AUDIO_CODEC_2.equals(audioStream.getCodec_name())) { // good container String ext = FilenameUtils.getExtension(conversionSetting.getOriginalVideoFile().getAbsolutePath()); if (MP4.equals(ext) && conversionSetting.getFfProbe().getFormat().getFormat_name().contains(MP4)) { return TYPE_NO_CHANGE; } return TYPE_JUST_CHANGE_CONTAINER; } return TYPE_CONVERT_ONLY_AUDIO; } // same file size uses 2 pass, other qualities uses CRF return conversionSetting.getQuality() == Settings.QUALITY_SAME_FILE_SIZE ? TYPE_TWO_PASS : TYPE_CRF; }
private String[] internalGetCrfSinglePass() { if (type != TYPE_CRF) return null; ArrayList<String> cmd = new ArrayList<String>(); cmd.add("ffmpeg"); cmd.add("-i"); cmd.add(conversionSetting.getOriginalVideoFile().getAbsolutePath()); cmd.add("-c:v"); cmd.add("libx264"); cmd.add("-profile:v"); cmd.add("high"); cmd.add("-level"); cmd.add("5"); cmd.add("-preset"); cmd.add(Settings.ARRAY_SPEED[conversionSetting.getSpeed()]); cmd.add("-crf"); switch (conversionSetting.getQuality()) { case Settings.QUALITY_SUPER: cmd.add("15"); break; case Settings.QUALITY_NORMAL: cmd.add("23"); break; case Settings.QUALITY_HIGH: default: cmd.add("18"); break; } String videoBitRate = getVideoBitrate(); if (videoBitRate != null) { cmd.add("-maxrate"); cmd.add(videoBitRate); cmd.add("-bufsize"); cmd.add("5M"); } addAudioConversion(cmd); cmd.add("-movflags"); cmd.add("+faststart"); cmd.add(conversionSetting.getTempVideoFile().getAbsolutePath()); return getArray(cmd); }