public static Boolean isTranscodeRequired(TranscodeProfile profile) {
    // Make sure we have the information we require
    if (profile.getMediaElement() == null
        || profile.getQuality() == null
        || profile.getCodecs() == null) {
      return null;
    }

    // Check video codec
    if (profile.getMediaElement().getVideoStream() != null) {
      if (isTranscodeRequired(profile, profile.getMediaElement().getVideoStream())) {
        return true;
      }
    }

    // Check audio streams
    if (profile.getMediaElement().getAudioStreams() != null) {
      for (AudioStream stream : profile.getMediaElement().getAudioStreams()) {
        if (isTranscodeRequired(profile, stream)) {
          return true;
        }
      }
    }

    // Check subtitle streams
    if (profile.getMediaElement().getSubtitleStreams() != null) {
      for (SubtitleStream stream : profile.getMediaElement().getSubtitleStreams()) {
        if (!isSupported(profile.getCodecs(), stream.getFormat())) {
          return true;
        }
      }
    }

    return false;
  }
  public Integer getForcedSubtitleIndex(MediaElement element) {
    // Check this is a video element
    if (element.getType() != MediaElementType.VIDEO) {
      return null;
    }

    // Get list of subtitle streams for video file
    List<SubtitleStream> subtitles = element.getSubtitleStreams();

    if (subtitles == null) {
      return null;
    }

    // Scan subtitles for forced streams
    for (SubtitleStream subtitle : subtitles) {
      if (subtitle.isForced()) {
        return subtitle.getStream();
      }
    }

    return null;
  }
  public static boolean processSubtitles(TranscodeProfile profile) {
    // Check variables
    if (profile.getMediaElement() == null
        || profile.getCodecs() == null
        || profile.getFormat() == null) {
      return false;
    }

    // Check this is a video element
    if (profile.getMediaElement().getType() != MediaElementType.VIDEO) {
      return false;
    }

    // If there are no streams to process we are done
    if (profile.getMediaElement().getSubtitleStreams() == null) {
      return true;
    }

    // Process each subtitle stream
    List<SubtitleTranscode> transcodes = new ArrayList<>();

    for (SubtitleStream stream : profile.getMediaElement().getSubtitleStreams()) {
      String codec = null;
      boolean hardcode = false;

      if (isSupported(profile.getCodecs(), stream.getFormat())
          && isSupported(getCodecsForFormat(profile.getFormat()), stream.getFormat())) {
        codec = "copy";
      } else if (isSupported(SUPPORTED_SUBTITLE_CODECS, stream.getFormat())) {
        codec = stream.getFormat();
        hardcode = true;
      }

      // Enable forced subtitles by default
      if (stream.isForced() && profile.getSubtitleTrack() == null) {
        profile.setSubtitleTrack(stream.getStream());
      }

      transcodes.add(new SubtitleTranscode(codec, hardcode));
    }

    // Update profile
    profile.setSubtitleTranscodes(transcodes.toArray(new SubtitleTranscode[transcodes.size()]));

    return true;
  }