added two new ffmpeg builder nodes

This commit is contained in:
John Andrews
2022-05-09 10:39:35 +12:00
parent d5e6e5122c
commit fa0a52c85e
4 changed files with 133 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
using FileFlows.VideoNodes.FfmpegBuilderNodes.Models;
namespace FileFlows.VideoNodes.FfmpegBuilderNodes;
public class FfmpegBuilderAddInputFile : FfmpegBuilderNode
{
public override string HelpUrl => "https://github.com/revenz/FileFlows/wiki/FFMPEG-Builder:-Add-Input-File";
public override string Icon => "fas fa-file-plus";
public override int Outputs => 2;
[TextVariable(1)]
[Required]
public string Pattern { get; set; }
[Boolean(2)]
public bool UseSourceDirectory { get; set; }
public override int Execute(NodeParameters args)
{
this.Init(args);
var dir = new FileInfo(UseSourceDirectory ? args.FileName : args.WorkingFile).Directory;
if (dir.Exists == false)
{
args.Logger?.ILog("Directory does not exist: " + dir.FullName);
return 2;
}
var regex = new Regex(this.Pattern, RegexOptions.IgnoreCase);
bool added = false;
foreach (var file in dir.GetFiles())
{
if (regex.IsMatch(file.Name) == false)
continue;
this.Model.InputFiles.Add(file.FullName);
added = true;
}
return added ? 1 : 2;
}
}

View File

@@ -0,0 +1,65 @@
using FileFlows.VideoNodes.FfmpegBuilderNodes.Models;
namespace FileFlows.VideoNodes.FfmpegBuilderNodes;
public class FfmpegBuilderSubtitleTrackMerge : FfmpegBuilderNode
{
public override string HelpUrl => "https://github.com/revenz/FileFlows/wiki/FFMPEG-Builder:-Subtitle-Track-Merge";
public override string Icon => "fas fa-comment-medical";
public override int Outputs => 2;
[Checklist(nameof(Options), 1)]
[Required]
public List<string> Subtitles { get; set; }
private static List<ListOption> _Options;
public static List<ListOption> Options
{
get
{
if (_Options == null)
{
_Options = new List<ListOption>
{
new ListOption { Value = "ass", Label = "ass: Advanced SubStation Alpha"},
new ListOption { Value = "srt", Label = "srt: SubRip subtitle"},
new ListOption { Value = "ssa", Label = "ssa: SubStation Alpha"},
new ListOption { Value = "sub", Label = "sub: SubStation Alpha"},
new ListOption { Value = "text", Label = "txt: Raw text subtitle"}
};
}
return _Options;
}
}
[Boolean(2)]
[DefaultValue(true)]
public bool UseSourceDirectory { get; set; } = true;
public override int Execute(NodeParameters args)
{
this.Init(args);
var dir = new FileInfo(UseSourceDirectory ? args.FileName : args.WorkingFile).Directory;
if (dir.Exists == false)
{
args.Logger?.ILog("Directory does not exist: " + dir.FullName);
return 2;
}
bool added = false;
foreach (var file in dir.GetFiles())
{
string ext = file.Extension;
if (string.IsNullOrEmpty(ext) || ext.Length < 2)
continue;
ext = ext.Substring(1).ToLower();// remove .
if (Subtitles.Contains(ext))
continue;
this.Model.InputFiles.Add(file.FullName);
added = true;
}
return added ? 1 : 2;
}
}

View File

@@ -168,6 +168,19 @@
"HardwareDecoding-Help": "If the executor should attempt to use hardware decoding. If not available the execution will proceed just without hardware decoding enabled."
}
},
"FfmpegBuilderAddInputFile": {
"Label": "FFMPEG Builder: Add Input File",
"Outputs": {
"1": "File found and added",
"2": "No file found"
},
"Fields": {
"Pattern": "Pattern",
"Pattern-Help": "A regular expression used to search for input files",
"UseSourceDirectory": "Use Source Directory",
"UseSourceDirectory-Help": "If checked the original source directory will be searched, otherwise the working directory will be used."
}
},
"FfmpegBuilderAudioAddTrack": {
"Label": "FFMPEG Builder: Audio Add Track",
"Outputs": {
@@ -332,6 +345,19 @@
"UseLanguageCode-Help": "If the language code of the audio track should be used instead of the title"
}
},
"FfmpegBuilderSubtitleTrackMerge": {
"Label": "FFMPEG Builder: Subtitle Track Merge",
"Outputs": {
"1": "Subtitles found and added",
"2": "No subtitles found"
},
"Fields": {
"Subtitles": "Subtitles",
"Subtitles-Help": "Select which subtitles to search for to add",
"UseSourceDirectory": "Use Source Directory",
"UseSourceDirectory-Help": "If checked the original source directory will be searched, otherwise the working directory will be used."
}
},
"FfmpegBuilderCropBlackBars": {
"Label": "FFMPEG Builder: Crop Black Bars",
"Description": "Updated FFMPEG Builder to crop black bars if detected",

View File

@@ -19,6 +19,7 @@
public bool RemoveAll { get; set; }
[Checklist(nameof(Options), 2)]
[ConditionEquals(nameof(RemoveAll), false)]
public List<string> SubtitlesToRemove { get; set; }
private static List<ListOption> _Options;