private String getVideoBitrate() { /* I found cases where mpeg1 streams return the uncompressed bitrate, rendering absurdly high bit rates. So we're getting the smaller from the two */ long br_stream = getVideoBitrateBasedOnVideoStreamBitRate(); long br_file = getVideoBitrateBasedOnFileBitrate(); long br = br_file > br_stream ? br_stream : br_file; if (br <= 0) return null; else return Long.toString(br); }
private void addAudioConversion(List<String> cmd) { cmd.add("-c:a"); cmd.add("libfdk_aac"); /* High Efficiency profile is giving trouble for some encodings. e.g.: pcm_s16le, 8000 Hz, 1 channels, s16, 128 kb/s (video from a mini camera I have) */ // cmd.add("-profile:a"); // cmd.add("aac_he"); cmd.add("-cutoff"); cmd.add("18000"); boolean bitRateAdded = false; Stream audioStream = getStream(CODEC_TYPE_AUDIO); String audioBitRate = audioStream.getBit_rate(); if (audioBitRate == null || audioBitRate.trim().length() == 0) { // if it doesn't have, just let FFMPEG do its default thing bitRateAdded = true; } else { try { long abr = Long.parseLong(audioBitRate); if (abr > Settings.getMaxPerChannelAudioBitRate(conversionSetting) * audioStream.getChannels()) { bitRateAdded = true; cmd.add("-b:a"); cmd.add( Long.toString( Settings.getMaxPerChannelAudioBitRate(conversionSetting) * audioStream.getChannels())); } } catch (Exception e) { /* number format */ } } if (!bitRateAdded) { cmd.add("-b:a"); cmd.add(audioBitRate); } }