package net.knarcraft.ffmpegconverter.streams; import net.knarcraft.ffmpegconverter.utility.SubtitleHelper; import org.jetbrains.annotations.NotNull; import java.util.Map; /** * An object representation of a subtitle stream in a media file */ public class SubtitleStream extends AbstractStream implements StreamObject { private final boolean isFullSubtitle; private final boolean isImageSubtitle; /** * Instantiates a new subtitle stream * * @param streamInfo

All info about the stream

* @param inputIndex

The index of the input file containing this stream

* @param relativeIndex

The index of the subtitle stream relative to other subtitle streams

*/ public SubtitleStream(@NotNull Map streamInfo, int inputIndex, int relativeIndex) { super(streamInfo, inputIndex, relativeIndex); this.isFullSubtitle = checkIfIsFullSubtitle(); this.isImageSubtitle = codecName != null && (getCodecName().equals("hdmv_pgs_subtitle") || getCodecName().equals("dvd_subtitle")); } /** * Gets whether the subtitle is an image subtitle * * @return

Whether the subtitles is an image subtitle.

*/ public boolean isImageSubtitle() { return this.isImageSubtitle; } /** * Gets whether the subtitle is a full subtitle * * @return

Whether the subtitle is a full subtitle.

*/ public boolean isFullSubtitle() { return this.isFullSubtitle; } /** * Checks whether the subtitle translates everything (as opposed to just songs and signs) * * @return

True if the subtitle translates everything.

*/ private boolean checkIfIsFullSubtitle() { return !SubtitleHelper.isSongsSignsSubtitle(this.getTitle()); } @Override public char streamTypeCharacter() { return 's'; } @Override @NotNull public String toString() { return super.toString() + " | Is full: " + this.isFullSubtitle; } }