diff --git a/VideoNodes/Helpers/SubtitleHelper.cs b/VideoNodes/Helpers/SubtitleHelper.cs
index c3f6699e..63f693ea 100644
--- a/VideoNodes/Helpers/SubtitleHelper.cs
+++ b/VideoNodes/Helpers/SubtitleHelper.cs
@@ -29,7 +29,7 @@ internal class SubtitleHelper
/// the subtitle codec
/// true if the subtitle is an image based subtitle
internal static bool IsImageSubtitle(string codec)
- => Regex.IsMatch(codec.Replace("_", ""), "dvbsub|pgs|xsub|vobsub", RegexOptions.IgnoreCase);
+ => Regex.IsMatch((codec ?? string.Empty).Replace("_", ""), "dvbsub|pgs|xsub|vobsub", RegexOptions.IgnoreCase);
///
/// Determines the appropriate subtitle codec for conversion based on the container type and current subtitle codec.
diff --git a/VideoNodes/VideoNodes.en.json b/VideoNodes/VideoNodes.en.json
index 66b1e4ad..db510c88 100644
--- a/VideoNodes/VideoNodes.en.json
+++ b/VideoNodes/VideoNodes.en.json
@@ -521,7 +521,9 @@
"SetWorkingFile": "Set as Working File",
"SetWorkingFile-Help": "When this is checked, if a subtitle is extracted, the working file will be changed to this extracted subtitle. The original working file will NOT be deleted.",
"ForcedOnly": "Forced Only",
- "ForcedOnly-Help": "If only forced subtitles should be extracted."
+ "ForcedOnly-Help": "If only forced subtitles should be extracted.",
+ "OnlyTextSubtitles": "Only Text Subtitles",
+ "OnlyTextSubtitles-Help": "If only text subtitles should be extracted, all image based subtitles will be skipped."
}
},
"VideoHasStream": {
diff --git a/VideoNodes/VideoNodes/SubtitleExtractor.cs b/VideoNodes/VideoNodes/SubtitleExtractor.cs
index f59977f6..0e0ba4b3 100644
--- a/VideoNodes/VideoNodes/SubtitleExtractor.cs
+++ b/VideoNodes/VideoNodes/SubtitleExtractor.cs
@@ -1,4 +1,5 @@
using System.Net;
+using FileFlows.VideoNodes.Helpers;
namespace FileFlows.VideoNodes;
@@ -40,7 +41,11 @@ public class SubtitleExtractor : EncodingNode
///
[Boolean(4)]
public bool ForcedOnly { get; set; }
-
+ ///
+ /// Gets or sets if only text subtitles should be extracted
+ ///
+ [Boolean(5)]
+ public bool OnlyTextSubtitles { get; set; }
private Dictionary _Variables;
///
@@ -75,6 +80,9 @@ public class SubtitleExtractor : EncodingNode
// ffmpeg -i input.mkv -map "0:m:language:eng" -map "-0:v" -map "-0:a" output.srt
var subTrack = videoInfo.SubtitleStreams?.Where(x =>
{
+ if (OnlyTextSubtitles && SubtitleHelper.IsImageSubtitle(x.Codec))
+ return false;
+
if (ForcedOnly && x.Forced == false)
return false;
if(string.IsNullOrEmpty(Language))
@@ -103,7 +111,7 @@ public class SubtitleExtractor : EncodingNode
OutputFile = args.MapPath(OutputFile);
string extension = "srt";
- if (subTrack.Codec?.ToLower()?.Contains("pgs") == true)
+ if (SubtitleHelper.IsImageSubtitle(subTrack.Codec))
extension = "sup";
if (OutputFile.ToLower().EndsWith(".srt") || OutputFile.ToLower().EndsWith(".sup"))
OutputFile = OutputFile[0..^4];