added subtitle remover

This commit is contained in:
reven
2021-12-18 11:34:09 +13:00
parent 10ab94aaf6
commit c95882fd3f
12 changed files with 112 additions and 3 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
FileFlows.Plugin.dll Normal file

Binary file not shown.

BIN
FileFlows.Plugin.pdb Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -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":{

View File

@@ -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<string> SubtitlesToRemove { get; set; }
private static List<ListOption> _Options;
public static List<ListOption> Options
{
get
{
if (_Options == null)
{
_Options = new List<ListOption>
{
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<string> ffArgs = new List<string>();
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<string>();
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;
}
}
}
}

View File

@@ -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"
}
]

BIN
ref/FileFlows.Plugin.dll Normal file

Binary file not shown.