mirror of
https://github.com/revenz/FileFlowsPlugins.git
synced 2025-12-21 02:09:35 -06:00
FF-1013 - added "strict" to ffmpeg builder executor
This commit is contained in:
@@ -1,6 +1,14 @@
|
||||
namespace FileFlows.DiscordNodes;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods
|
||||
/// </summary>
|
||||
internal static class ExtensionMethods
|
||||
{
|
||||
/// <summary>
|
||||
/// Treats an empty string as if it was null
|
||||
/// </summary>
|
||||
/// <param name="str">the input string</param>
|
||||
/// <returns>the string unless it was empty then null</returns>
|
||||
public static string? EmptyAsNull(this string str) => str == string.Empty ? null : str;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,26 @@
|
||||
namespace FileFlows.DiscordNodes;
|
||||
|
||||
/// <summary>
|
||||
/// The plugin information
|
||||
/// </summary>
|
||||
public class Plugin : FileFlows.Plugin.IPlugin
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the UID of this plugin
|
||||
/// </summary>
|
||||
public Guid Uid => new Guid("ebaea108-8783-46b2-a889-be0d79bc8ad6");
|
||||
/// <summary>
|
||||
/// Gets the name of this plugin
|
||||
/// </summary>
|
||||
public string Name => "Discord";
|
||||
/// <summary>
|
||||
/// Gets the minimum version this plugin supports
|
||||
/// </summary>
|
||||
public string MinimumVersion => "1.0.4.2019";
|
||||
|
||||
/// <summary>
|
||||
/// Initializes this plugin
|
||||
/// </summary>
|
||||
public void Init()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -1,18 +1,21 @@
|
||||
namespace FileFlows.DiscordNodes
|
||||
namespace FileFlows.DiscordNodes;
|
||||
|
||||
/// <summary>
|
||||
/// THe Plugin settings
|
||||
/// </summary>
|
||||
public class PluginSettings:IPluginSettings
|
||||
{
|
||||
using FileFlows.Plugin;
|
||||
using FileFlows.Plugin.Attributes;
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
/// <summary>
|
||||
/// Gets or sets the webhook id for this plugin
|
||||
/// </summary>
|
||||
[Text(1)]
|
||||
[Required]
|
||||
public string WebhookId { get; set; }
|
||||
|
||||
public class PluginSettings:IPluginSettings
|
||||
{
|
||||
[Text(1)]
|
||||
[Required]
|
||||
public string WebhookId { get; set; }
|
||||
|
||||
[Text(2)]
|
||||
[Required]
|
||||
public string WebhookToken { get; set; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets or sets the webhook token for this plugin
|
||||
/// </summary>
|
||||
[Text(2)]
|
||||
[Required]
|
||||
public string WebhookToken { get; set; }
|
||||
}
|
||||
|
||||
@@ -26,9 +26,21 @@ namespace FileFlows.VideoNodes
|
||||
this.Logger = logger;
|
||||
}
|
||||
|
||||
public (bool successs, string output) Encode(string input, string output, List<string> arguments, bool dontAddInputFile = false, bool dontAddOutputFile = false)
|
||||
/// <summary>
|
||||
/// Encodes using FFmpeg
|
||||
/// </summary>
|
||||
/// <param name="input">the input file</param>
|
||||
/// <param name="output">the output file</param>
|
||||
/// <param name="arguments">the FFmpeg arguments</param>
|
||||
/// <param name="dontAddInputFile">if the input file should not be added to the arguments</param>
|
||||
/// <param name="dontAddOutputFile">if the output file should not be added to the arguments</param>
|
||||
/// <param name="strictness">the strictness to use</param>
|
||||
/// <returns>the result and output of the encode</returns>
|
||||
public (bool successs, string output) Encode(string input, string output, List<string> arguments, bool dontAddInputFile = false, bool dontAddOutputFile = false, string strictness = "-2")
|
||||
{
|
||||
arguments ??= new List<string> ();
|
||||
if (string.IsNullOrWhiteSpace(strictness))
|
||||
strictness = "-2";
|
||||
|
||||
// -y means it will overwrite a file if output already exists
|
||||
if (dontAddInputFile == false) {
|
||||
@@ -42,7 +54,7 @@ namespace FileFlows.VideoNodes
|
||||
if (arguments.Last() != "-")
|
||||
{
|
||||
// strict -2 needs to be just before the output file
|
||||
arguments.AddRange(new[] { "-strict", "-2" }); // allow experimental stuff
|
||||
arguments.AddRange(new[] { "-strict", strictness });
|
||||
arguments.Add(output);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -16,9 +16,43 @@ public class FfmpegBuilderExecutor: FfmpegBuilderNode
|
||||
|
||||
public override bool NoEditorOnAdd => true;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets if hardware decoding should be used
|
||||
/// </summary>
|
||||
[DefaultValue(true)]
|
||||
[Boolean(1)]
|
||||
public bool HardwareDecoding { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the strictness
|
||||
/// </summary>
|
||||
[DefaultValue("experimental")]
|
||||
[Select(nameof(StrictOptions), 2)]
|
||||
public string Strictness { get; set; }
|
||||
|
||||
private static List<ListOption> _StrictOptions;
|
||||
/// <summary>
|
||||
/// Gets the strict options
|
||||
/// </summary>
|
||||
public static List<ListOption> StrictOptions
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_StrictOptions == null)
|
||||
{
|
||||
_StrictOptions = new List<ListOption>
|
||||
{
|
||||
new () { Label = "Experimental", Value = "experimental" },
|
||||
new () { Label = "Unofficial", Value = "unofficial" },
|
||||
new () { Label = "Normal", Value = "normal" },
|
||||
new () { Label = "Strict", Value = "strict" },
|
||||
new () { Label = "Very", Value = "very" },
|
||||
};
|
||||
}
|
||||
return _StrictOptions;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public override int Execute(NodeParameters args)
|
||||
{
|
||||
@@ -145,26 +179,6 @@ public class FfmpegBuilderExecutor: FfmpegBuilderNode
|
||||
ffArgs.AddRange(new[] { "-map", "0:t?", "-c:t", "copy" });
|
||||
var ffmpeg = FFMPEG;
|
||||
|
||||
// string strFfArgs = string.Join(" ", ffArgs);
|
||||
// if ((strFfArgs.Contains("libaom-av1") || strFfArgs.Contains("libsvtav1")))
|
||||
// {
|
||||
// args.Logger.DLog("Using AV1");
|
||||
// if (File.Exists(ffmpeg + "-av1"))
|
||||
// {
|
||||
// ffmpeg = ffmpeg + "-av1";
|
||||
// if(ffArgs.IndexOf("-hwaccel") > 0)
|
||||
// {
|
||||
// ffArgs.RemoveRange(ffArgs.IndexOf("-hwaccel"), 2);
|
||||
// if(ffArgs.IndexOf("-hwaccel_output_format") > 0)
|
||||
// {
|
||||
// ffArgs.RemoveRange(ffArgs.IndexOf("-hwaccel_output_format"), 2);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// args.Logger.DLog("Did not find custom FFMPEG AV1: " + ffmpeg + "-av1");
|
||||
// }
|
||||
|
||||
if(string.IsNullOrWhiteSpace(model.PreExecuteCode) == false)
|
||||
{
|
||||
var preExecutor = new PreExecutor(args, model.PreExecuteCode, ffArgs);
|
||||
@@ -178,7 +192,7 @@ public class FfmpegBuilderExecutor: FfmpegBuilderNode
|
||||
}
|
||||
|
||||
|
||||
if (Encode(args, ffmpeg, ffArgs, extension, dontAddInputFile: true) == false)
|
||||
if (Encode(args, ffmpeg, ffArgs, extension, dontAddInputFile: true, strictness: Strictness) == false)
|
||||
return -1;
|
||||
|
||||
foreach (var file in model.InputFiles)
|
||||
|
||||
@@ -62,7 +62,9 @@
|
||||
"Description": "Executes a FFMPEG Builder command created by other FFMPEG Builder nodes.",
|
||||
"Fields": {
|
||||
"HardwareDecoding": "Hardware Decoding",
|
||||
"HardwareDecoding-Help": "If the executor should attempt to use hardware decoding. If not available the execution will proceed just without hardware decoding enabled."
|
||||
"HardwareDecoding-Help": "If the executor should attempt to use hardware decoding. If not available the execution will proceed just without hardware decoding enabled.",
|
||||
"Strictness": "Strictness",
|
||||
"Strictness-Help": "Allows you to customize the strictness of FFmpeg. This should be left on 'Experimental' for most users."
|
||||
}
|
||||
},
|
||||
"FfmpegBuilderAddInputFile": {
|
||||
|
||||
@@ -16,13 +16,40 @@ namespace FileFlows.VideoNodes
|
||||
|
||||
private FFMpegEncoder Encoder;
|
||||
|
||||
public bool Encode(NodeParameters args, string ffmpegExe, List<string> ffmpegParameters, string extension = "mkv", string outputFile = "", bool updateWorkingFile = true, bool dontAddInputFile = false, bool dontAddOutputFile = false)
|
||||
/// <summary>
|
||||
/// Encodes a video
|
||||
/// </summary>
|
||||
/// <param name="args">the node parameters</param>
|
||||
/// <param name="ffmpegExe">the FFmpeg executable</param>
|
||||
/// <param name="ffmpegParameters">the FFmpeg parameters</param>
|
||||
/// <param name="extension">the output fil extension</param>
|
||||
/// <param name="outputFile">the output file</param>
|
||||
/// <param name="updateWorkingFile">if the working file should be updated to the newly created file</param>
|
||||
/// <param name="dontAddInputFile">if the input file should not be added to the arguments</param>
|
||||
/// <param name="dontAddOutputFile">if the output file should not be added to the arguments</param>
|
||||
/// <param name="strictness">the strictness to use</param>
|
||||
/// <returns>true if the encode was successful</returns>
|
||||
public bool Encode(NodeParameters args, string ffmpegExe, List<string> ffmpegParameters, string extension = "mkv", string outputFile = "", bool updateWorkingFile = true, bool dontAddInputFile = false, bool dontAddOutputFile = false, string strictness = "-2")
|
||||
{
|
||||
string output;
|
||||
return Encode(args, ffmpegExe, ffmpegParameters, out output, extension, outputFile, updateWorkingFile, dontAddInputFile: dontAddInputFile, dontAddOutputFile: dontAddOutputFile);
|
||||
return Encode(args, ffmpegExe, ffmpegParameters, out output, extension, outputFile, updateWorkingFile, dontAddInputFile: dontAddInputFile, dontAddOutputFile: dontAddOutputFile, strictness: strictness);
|
||||
}
|
||||
|
||||
public bool Encode(NodeParameters args, string ffmpegExe, List<string> ffmpegParameters, out string output, string extension = "mkv", string outputFile = "", bool updateWorkingFile = true, bool dontAddInputFile = false, bool dontAddOutputFile = false)
|
||||
/// <summary>
|
||||
/// Encodes a video
|
||||
/// </summary>
|
||||
/// <param name="args">the node parameters</param>
|
||||
/// <param name="ffmpegExe">the FFmpeg executable</param>
|
||||
/// <param name="ffmpegParameters">the FFmpeg parameters</param>
|
||||
/// <param name="output">the output from the command</param>
|
||||
/// <param name="extension">the output fil extension</param>
|
||||
/// <param name="outputFile">the output file</param>
|
||||
/// <param name="updateWorkingFile">if the working file should be updated to the newly created file</param>
|
||||
/// <param name="dontAddInputFile">if the input file should not be added to the arguments</param>
|
||||
/// <param name="dontAddOutputFile">if the output file should not be added to the arguments</param>
|
||||
/// <param name="strictness">the strictness to use</param>
|
||||
/// <returns>true if the encode was successful</returns>
|
||||
public bool Encode(NodeParameters args, string ffmpegExe, List<string> ffmpegParameters, out string output, string extension = "mkv", string outputFile = "", bool updateWorkingFile = true, bool dontAddInputFile = false, bool dontAddOutputFile = false, string strictness = "-2")
|
||||
{
|
||||
if (string.IsNullOrEmpty(extension))
|
||||
extension = "mkv";
|
||||
@@ -43,7 +70,7 @@ namespace FileFlows.VideoNodes
|
||||
}
|
||||
}
|
||||
|
||||
var success = Encoder.Encode(args.WorkingFile, outputFile, ffmpegParameters, dontAddInputFile: dontAddInputFile, dontAddOutputFile: dontAddOutputFile);
|
||||
var success = Encoder.Encode(args.WorkingFile, outputFile, ffmpegParameters, dontAddInputFile: dontAddInputFile, dontAddOutputFile: dontAddOutputFile, strictness: strictness);
|
||||
args.Logger.ILog("Encoding successful: " + success.successs);
|
||||
if (success.successs && updateWorkingFile)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user