Files
FFmpegConvert/src/main/java/net/knarcraft/ffmpegconverter/streams/SubtitleStream.java
EpicKnarvik97 1ceb378757
All checks were successful
KnarCraft/FFmpegConvert/pipeline/head This commit looks good
Various smaller improvements
Improves Signs & Songs subtitle RegEx
Adds tests for the Signs & Songs subtitle RegEx
Automatically changes "enm" language to English
Makes the downscale converter select HEVC if the input is HEVC
2024-06-07 15:46:51 +02:00

68 lines
2.0 KiB
Java

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 <p>All info about the stream</p>
* @param inputIndex <p>The index of the input file containing this stream</p>
* @param relativeIndex <p>The index of the subtitle stream relative to other subtitle streams</p>
*/
public SubtitleStream(@NotNull Map<StreamTag, String> 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 <p>Whether the subtitles is an image subtitle.</p>
*/
public boolean isImageSubtitle() {
return this.isImageSubtitle;
}
/**
* Gets whether the subtitle is a full subtitle
*
* @return <p>Whether the subtitle is a full subtitle.</p>
*/
public boolean isFullSubtitle() {
return this.isFullSubtitle;
}
/**
* Checks whether the subtitle translates everything (as opposed to just songs and signs)
*
* @return <p>True if the subtitle translates everything.</p>
*/
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;
}
}