private int internalGetNumberOfSubtitles() { int numberOfSubtitles = 0; for (Stream s : conversionSetting.getFfProbe().getStreams()) { if (CODEC_TYPE_SUBTITLE.equals(s.getCodec_type()) && !INVALID_SUBTITLE.equals(s.getCodec_name())) { numberOfSubtitles++; } } return numberOfSubtitles; }
private String[] internalGetSubtitle(int position) { Stream subtitle = null; int subtitleIndex = 0; for (int streamIndex = 0; streamIndex < conversionSetting.getFfProbe().getStreams().size(); streamIndex++) { Stream s = conversionSetting.getFfProbe().getStreams().get(streamIndex); if (CODEC_TYPE_SUBTITLE.equals(s.getCodec_type()) && !INVALID_SUBTITLE.equals(s.getCodec_name())) { if (position == subtitleIndex) { subtitle = s; } subtitleIndex++; // increment for all valid subtitles } } if (subtitle == null) return null; // get the language code for the filename String language = null; Tags t = subtitle.getTags(); if (t != null) { language = t.getLanguage(); } if (language == null) language = "DEFAULT"; File fileName = conversionSetting.getSubtitleFileName(language); ArrayList<String> cmd = new ArrayList<String>(); cmd.add("ffmpeg"); cmd.add("-i"); cmd.add(conversionSetting.getOriginalVideoFile().getAbsolutePath()); cmd.add("-vn"); cmd.add("-an"); cmd.add("-map"); cmd.add("0:s:" + position); cmd.add(fileName.getAbsolutePath()); return getArray(cmd); }