mirror of
https://github.com/revenz/FileFlowsPlugins.git
synced 2026-02-13 23:08:26 -06:00
added ffmpeg builder custom parameters node
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Emby/Emby.csproj
BIN
Emby/Emby.csproj
Binary file not shown.
BIN
Emby/Plugin.cs
BIN
Emby/Plugin.cs
Binary file not shown.
Binary file not shown.
BIN
Gotify/Plugin.cs
BIN
Gotify/Plugin.cs
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Plex/Plex.csproj
BIN
Plex/Plex.csproj
Binary file not shown.
BIN
Plex/Plugin.cs
BIN
Plex/Plugin.cs
Binary file not shown.
@@ -0,0 +1,68 @@
|
||||
using FileFlows.VideoNodes.FfmpegBuilderNodes.Models;
|
||||
|
||||
namespace FileFlows.VideoNodes.FfmpegBuilderNodes;
|
||||
|
||||
/// <summary>
|
||||
/// Node that adds custom parameters to the FFMPEG Builder
|
||||
/// </summary>
|
||||
public class FfmpegBuilderCustomParameters : FfmpegBuilderNode
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the Help URL for this node
|
||||
/// </summary>
|
||||
public override string HelpUrl => "https://docs.fileflows.com/plugins/video-nodes/ffmpeg-builder/custom-parameters";
|
||||
|
||||
/// <summary>
|
||||
/// Gets the icon for this node
|
||||
/// </summary>
|
||||
public override string Icon => "fas fa-plus-square";
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of outputs for this node
|
||||
/// </summary>
|
||||
public override int Outputs => 1;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the parameters to add
|
||||
/// </summary>
|
||||
[TextVariable(1)]
|
||||
[Required]
|
||||
public string Parameters { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets if the video should be forcable encoded when these parameters are added
|
||||
/// </summary>
|
||||
[Boolean(2)]
|
||||
[DefaultValue(true)]
|
||||
public bool ForceEncode { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Executes the node
|
||||
/// </summary>
|
||||
/// <param name="args">the node parameters</param>
|
||||
/// <returns>the output number to execute next</returns>
|
||||
public override int Execute(NodeParameters args)
|
||||
{
|
||||
string parameters = args.ReplaceVariables(Parameters);
|
||||
if (string.IsNullOrWhiteSpace(parameters))
|
||||
return 1;
|
||||
|
||||
string[] split = Regex.Split(parameters, "(\"[^\"]+\"|[^\\s\"]+)");
|
||||
foreach(var parameter in split)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(parameter))
|
||||
continue;
|
||||
|
||||
string actual = parameter;
|
||||
if (parameter.StartsWith("\"") && parameter.EndsWith("\""))
|
||||
actual = parameter[1..^1];
|
||||
this.Model.CustomParameters.Add(actual);
|
||||
}
|
||||
|
||||
this.Model.ForceEncode = ForceEncode;
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,10 @@ namespace FileFlows.VideoNodes.FfmpegBuilderNodes
|
||||
List<string> ffArgs = new List<string>();
|
||||
ffArgs.AddRange(new[] { "-strict", "-2" }); // allow experimental stuff
|
||||
ffArgs.AddRange(new[] { "-fflags", "+genpts" }); //Generate missing PTS if DTS is present.
|
||||
|
||||
if(model.CustomParameters?.Any() == true)
|
||||
ffArgs.AddRange(model.CustomParameters);
|
||||
|
||||
bool hasChange = false;
|
||||
int actualIndex = 0;
|
||||
int currentType = 0;
|
||||
@@ -53,7 +57,7 @@ namespace FileFlows.VideoNodes.FfmpegBuilderNodes
|
||||
ffArgs.AddRange(model.MetadataParameters);
|
||||
}
|
||||
|
||||
if (hasChange == false && (string.IsNullOrWhiteSpace(model.Extension) || args.WorkingFile.ToLower().EndsWith("." + model.Extension.ToLower())))
|
||||
if (model.ForceEncode == false && hasChange == false && (string.IsNullOrWhiteSpace(model.Extension) || args.WorkingFile.ToLower().EndsWith("." + model.Extension.ToLower())))
|
||||
return 2; // nothing to do
|
||||
|
||||
string extension = model.Extension?.EmptyAsNull() ?? "mkv";
|
||||
|
||||
@@ -37,6 +37,22 @@
|
||||
set => _InputFiles = value ?? new List<string>();
|
||||
}
|
||||
|
||||
private List<string> _CustomParameters = new List<string>();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets custom parameters to use in the FFMPEG Builder
|
||||
/// </summary>
|
||||
public List<string> CustomParameters
|
||||
{
|
||||
get => _CustomParameters;
|
||||
set => _CustomParameters = value ?? new List<string>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets if the builder should forcable execute even if nothing appears to have changed
|
||||
/// </summary>
|
||||
public bool ForceEncode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the video information for this video file
|
||||
/// </summary>
|
||||
|
||||
Binary file not shown.
@@ -1056,6 +1056,39 @@ public class FfmpegBuilder_BasicTests
|
||||
string log = logger.ToString();
|
||||
Assert.AreEqual(1, result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
[TestMethod]
|
||||
public void FfmpegBuilder_CustomParameters()
|
||||
{
|
||||
const string file = @"D:\videos\testfiles\basic.mkv";
|
||||
var logger = new TestLogger();
|
||||
const string ffmpeg = @"C:\utils\ffmpeg\ffmpeg.exe";
|
||||
var vi = new VideoInfoHelper(ffmpeg, logger);
|
||||
var vii = vi.Read(file);
|
||||
var args = new NodeParameters(file, logger, false, string.Empty);
|
||||
args.GetToolPathActual = (string tool) => ffmpeg;
|
||||
args.TempPath = @"D:\videos\temp";
|
||||
args.Parameters.Add("VideoInfo", vii);
|
||||
|
||||
FfmpegBuilderStart ffStart = new();
|
||||
ffStart.PreExecute(args);
|
||||
Assert.AreEqual(1, ffStart.Execute(args));
|
||||
|
||||
FfmpegBuilderCustomParameters ffCustom = new();
|
||||
ffCustom.Parameters = "this is a \"testing bobby drake\" blah";
|
||||
ffCustom.ForceEncode = true;
|
||||
ffCustom.PreExecute(args);
|
||||
ffCustom.Execute(args);
|
||||
|
||||
FfmpegBuilderExecutor ffExecutor = new();
|
||||
ffExecutor.PreExecute(args);
|
||||
int result = ffExecutor.Execute(args);
|
||||
|
||||
string log = logger.ToString();
|
||||
Assert.IsTrue(log.Contains("this is a \"testing bobby drake\" blah"));
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
Binary file not shown.
@@ -329,6 +329,19 @@
|
||||
"2": "No commercials detected"
|
||||
}
|
||||
},
|
||||
"FfmpegBuilderCustomParameters": {
|
||||
"Label": "FFMPEG Builder: Custom Parameters",
|
||||
"Description": "Lets you add custom parameters to the FFMPEG Builder for execution",
|
||||
"Outputs": {
|
||||
"1": "Parameters added"
|
||||
},
|
||||
"Fields": {
|
||||
"Parameters": "Parameters",
|
||||
"Parameters-Help": "The parameters to add to the FFMPEG Builder for execution",
|
||||
"ForceEncode": "Force Encode",
|
||||
"ForceEncode-Help": "If this should force the FFMPEG Builder Executor to always execute even if no changes are detected that would usually require the executor to run."
|
||||
}
|
||||
},
|
||||
"FfmpegBuilderHdrToSdr": {
|
||||
"Label": "FFMPEG Builder: HDR to SDR",
|
||||
"Description": "Checks if a video stream is HDR and if it is updates the FFMPEG Builder to convert it to SDR",
|
||||
|
||||
Reference in New Issue
Block a user