private long getVideoBitrateBasedOnFileBitrate() {
    // file bitrate
    String fileBitrate = conversionSetting.getFfProbe().getFormat().getBit_rate();
    long fbr;
    if (fileBitrate == null || fileBitrate.trim().length() == 0) {
      return 0l;
    } else {
      try {
        fbr = Long.parseLong(fileBitrate);
      } catch (Exception e) {
        // number format exception
        return 0l;
      }
    }

    // audio bitrate
    long abr;
    Stream audioStream = getStream(CODEC_TYPE_AUDIO);
    String audioBitrate = audioStream.getBit_rate();
    try {
      abr = Long.parseLong(audioBitrate);
    } catch (Exception e) {
      // number format exception
      abr = Settings.getDefaultPerChannelAudioBitRate() * audioStream.getChannels();
    }

    return fbr - abr;
  }
 private long getVideoBitrateBasedOnVideoStreamBitRate() {
   Stream videoStream = getStream(CODEC_TYPE_VIDEO);
   try {
     return Long.parseLong(videoStream.getBit_rate());
   } catch (Exception e) {
     // number format exception
     return 0l;
   }
 }
  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);
    }
  }