diff --git a/BasicNodes/BasicNodes.csproj b/BasicNodes/BasicNodes.csproj index 6295d851..bf69528a 100644 Binary files a/BasicNodes/BasicNodes.csproj and b/BasicNodes/BasicNodes.csproj differ diff --git a/Builds/BasicNodes.zip b/Builds/BasicNodes.zip index 8042e5bc..077a8b10 100644 Binary files a/Builds/BasicNodes.zip and b/Builds/BasicNodes.zip differ diff --git a/Builds/MetaNodes.zip b/Builds/MetaNodes.zip index b70217ec..f5dc0c7b 100644 Binary files a/Builds/MetaNodes.zip and b/Builds/MetaNodes.zip differ diff --git a/Builds/VideoNodes.zip b/Builds/VideoNodes.zip index c8a8922d..db896f69 100644 Binary files a/Builds/VideoNodes.zip and b/Builds/VideoNodes.zip differ diff --git a/FileFlows.Plugin.dll b/FileFlows.Plugin.dll new file mode 100644 index 00000000..7130055c Binary files /dev/null and b/FileFlows.Plugin.dll differ diff --git a/FileFlows.Plugin.pdb b/FileFlows.Plugin.pdb new file mode 100644 index 00000000..8e93f588 Binary files /dev/null and b/FileFlows.Plugin.pdb differ diff --git a/MetaNodes/MetaNodes.csproj b/MetaNodes/MetaNodes.csproj index 13744732..07a05e2f 100644 Binary files a/MetaNodes/MetaNodes.csproj and b/MetaNodes/MetaNodes.csproj differ diff --git a/VideoNodes/VideoNodes.csproj b/VideoNodes/VideoNodes.csproj index a3103aaa..a6c13cdc 100644 Binary files a/VideoNodes/VideoNodes.csproj and b/VideoNodes/VideoNodes.csproj differ diff --git a/VideoNodes/VideoNodes.en.json b/VideoNodes/VideoNodes.en.json index bd024c7f..dbb4c110 100644 --- a/VideoNodes/VideoNodes.en.json +++ b/VideoNodes/VideoNodes.en.json @@ -11,6 +11,12 @@ "CroppingThreshold-Help": "The amount of pixels that must be greater than to crop. E.g. if there's only 5 pixels detected as black space, you may consider this too small to crop." } }, + "SubtitleRemover":{ + "Description": "Removes subtitles from a video file if found..\n\nOutput 1: Subtitles were removed\nOutput 2: No subtitles found that needed to be removed", + "Fields": { + "SubtitlesToRemove": "Subtitles To Remove" + } + }, "VideoCodec":{ "Description":"This node will check the codecs in the input file, and trigger when matched.\n\nOutput 1: Matches\nOutput 2: Does not match", "Fields":{ diff --git a/VideoNodes/VideoNodes/SubtitleRemover.cs b/VideoNodes/VideoNodes/SubtitleRemover.cs new file mode 100644 index 00000000..7f9eb4f9 --- /dev/null +++ b/VideoNodes/VideoNodes/SubtitleRemover.cs @@ -0,0 +1,103 @@ +namespace FileFlows.VideoNodes +{ + using FileFlows.Plugin; + using FileFlows.Plugin.Attributes; + using System; + using System.Collections.Generic; + using System.Linq; + using System.Text; + using System.Threading.Tasks; + + public class SubtitleRemover: EncodingNode + { + public override int Outputs => 2; + + public override string Icon => "fas fa-comment"; + + [Checklist(nameof(Options), 1)] + public List SubtitlesToRemove { get; set; } + + private static List _Options; + public static List Options + { + get + { + if (_Options == null) + { + _Options = new List + { + new ListOption { Value = "mov_text", Label = "3GPP Timed Text subtitle"}, + new ListOption { Value = "ssa", Label = "ASS (Advanced SubStation Alpha) subtitle (codec ass)"}, + new ListOption { Value = "ass", Label = "ASS (Advanced SubStation Alpha) subtitle"}, + new ListOption { Value = "xsub", Label = "DivX subtitles (XSUB)" }, + new ListOption { Value = "dvbsub", Label = "DVB subtitles (codec dvb_subtitle)"}, + new ListOption { Value = "dvdsub", Label = "DVD subtitles (codec dvd_subtitle)"}, + new ListOption { Value = "text", Label = "Raw text subtitle"}, + new ListOption { Value = "subrip", Label = "SubRip subtitle"}, + new ListOption { Value = "srt", Label = "SubRip subtitle (codec subrip)"}, + new ListOption { Value = "ttml", Label = "TTML subtitle"}, + new ListOption { Value = "webvtt", Label = "WebVTT subtitle"}, + }; + } + return _Options; + } + } + + public override int Execute(NodeParameters args) + { + try + { + VideoInfo videoInfo = GetVideoInfo(args); + if (videoInfo == null) + return -1; + + string ffmpegExe = GetFFMpegExe(args); + if (string.IsNullOrEmpty(ffmpegExe)) + return -1; + + List ffArgs = new List(); + ffArgs.Add($"-c:v copy"); + ffArgs.Add($"-c:a copy"); + + var removeCodecs = SubtitlesToRemove?.Where(x => string.IsNullOrWhiteSpace(x) == false)?.Select(x => x.ToLower())?.ToList() ?? new List(); + + if (removeCodecs.Count == 0) + return 2; // nothing to remove + + bool foundBadSubtitle = false; + + foreach (var sub in videoInfo.SubtitleStreams) + { + if (removeCodecs.Contains(sub.Codec.ToLower())) + { + foundBadSubtitle = true; + continue; + } + ffArgs.Add("-map 0:s:" + sub.TypeIndex); + } + + if(foundBadSubtitle == false) + { + // nothing to remove + return 2; + } + + string ffArgsLine = string.Join(" ", ffArgs); + + string extension = new FileInfo(args.WorkingFile).Extension; + if(extension.StartsWith(".")) + extension = extension.Substring(1); + + if (Encode(args, ffmpegExe, ffArgsLine, extension) == false) + return -1; + + return 1; + } + catch (Exception ex) + { + args.Logger?.ELog("Failed processing VideoFile: " + ex.Message); + return -1; + } +} + } +} diff --git a/plugins.json b/plugins.json index ef58ea5e..5c24e3e6 100644 --- a/plugins.json +++ b/plugins.json @@ -1,17 +1,17 @@ [ { "Name": "BasicNodes", - "Version": "0.0.1.30", + "Version": "0.0.1.31", "Package": "https://github.com/revenz/FileFlowsPlugins/blob/master/Builds/BasicNodes.zip?raw=true" }, { "Name": "MetaNodes", - "Version": "0.0.1.30", + "Version": "0.0.1.31", "Package": "https://github.com/revenz/FileFlowsPlugins/blob/master/Builds/MetaNodes.zip?raw=true" }, { "Name": "VideoNodes", - "Version": "0.0.1.30", + "Version": "0.0.1.31", "Package": "https://github.com/revenz/FileFlowsPlugins/blob/master/Builds/VideoNodes.zip?raw=true" } ] diff --git a/ref/FileFlows.Plugin.dll b/ref/FileFlows.Plugin.dll new file mode 100644 index 00000000..3ad80cec Binary files /dev/null and b/ref/FileFlows.Plugin.dll differ