From 97bd00a258c433d7d8e1ea03cb50bef55c0fd9ca Mon Sep 17 00:00:00 2001 From: John Andrews Date: Sat, 9 Jul 2022 23:30:04 +1200 Subject: [PATCH] added max bitrate node --- DiscordNodes/Communication/Discord.cs | 1 + .../Video/FfmpegBuilderVideoMaxBitrate.cs | 40 +++++++++++++++ VideoNodes/VideoNodes.csproj | 49 ------------------- VideoNodes/VideoNodes.en.json | 12 +++++ 4 files changed, 53 insertions(+), 49 deletions(-) create mode 100644 VideoNodes/FfmpegBuilderNodes/Video/FfmpegBuilderVideoMaxBitrate.cs diff --git a/DiscordNodes/Communication/Discord.cs b/DiscordNodes/Communication/Discord.cs index 142a7bbf..2b20bbba 100644 --- a/DiscordNodes/Communication/Discord.cs +++ b/DiscordNodes/Communication/Discord.cs @@ -10,6 +10,7 @@ public class Discord: Node public override FlowElementType Type => FlowElementType.Communication; public override string Icon => "fab fa-discord"; public override bool FailureNode => true; + public override string HelpUrl => "https://docs.fileflows.com/plugins/discord/discord"; [Required] [TextVariable(1)] diff --git a/VideoNodes/FfmpegBuilderNodes/Video/FfmpegBuilderVideoMaxBitrate.cs b/VideoNodes/FfmpegBuilderNodes/Video/FfmpegBuilderVideoMaxBitrate.cs new file mode 100644 index 00000000..6b41c695 --- /dev/null +++ b/VideoNodes/FfmpegBuilderNodes/Video/FfmpegBuilderVideoMaxBitrate.cs @@ -0,0 +1,40 @@ +namespace FileFlows.VideoNodes.FfmpegBuilderNodes; + +/// +/// Node that limits the bitrate for video +/// +public class FfmpegBuilderVideoMaxBitrate : FfmpegBuilderNode +{ + public override string HelpUrl => "https://docs.fileflows.com/plugins/video-nodes/ffmpeg-builder/video-max-bitrate"; + + /// + /// Gets or sets the maximum bitrate in K + /// + [NumberInt(1)] + [DefaultValue(10_000)] + public float Bitrate { get; set; } + + + public override int Execute(NodeParameters args) + { + var video = Model.VideoStreams?.Where(x => x.Deleted == false)?.FirstOrDefault(); + if (video?.Stream == null) + { + args.Logger?.ELog("No video stream found"); + return -1; + } + if(Bitrate < 0) + { + args.Logger?.ELog("Minimum bitrate not set"); + return -1; + } + + video.AdditionalParameters.AddRange(new[] + { + "-b:v:{index}", + "-maxrate", Bitrate + "k" + }); + + return 1; + } +} diff --git a/VideoNodes/VideoNodes.csproj b/VideoNodes/VideoNodes.csproj index 768ab16a..e69de29b 100644 --- a/VideoNodes/VideoNodes.csproj +++ b/VideoNodes/VideoNodes.csproj @@ -1,49 +0,0 @@ - - - - net6.0 - enable - enable - true - true - 0.8.4.152 - 0.8.4.152 - true - FileFlows - John Andrews - Video Nodes - https://fileflows.com/ - Nodes for processing video files. This plugin contains nodes to convert video files to different formats. Node to parse the video information from a file. - FileFlows.$(MSBuildProjectName.Replace(" ", "_")) - - - - 1701;1702;CS8618;CS8601;CS8602;CS8603;CS8604;CS8618;CS8625;CS8765;CS8767; - 0 - - - - 1701;1702;CS8618;CS8601;CS8602;CS8603;CS8604;CS8618;CS8625;CS8765;CS8767; - 0 - - - - - - - - - - - Always - - - - - - ..\FileFlows.Plugin.dll - False - - - - diff --git a/VideoNodes/VideoNodes.en.json b/VideoNodes/VideoNodes.en.json index 7971d2af..5c413f0d 100644 --- a/VideoNodes/VideoNodes.en.json +++ b/VideoNodes/VideoNodes.en.json @@ -369,6 +369,18 @@ "Percent-Help": "When selected the bitrate will be calculated as a percentage of the current bitrate." } }, + "FfmpegBuilderVideoMaxBitrate": { + "Label": "FFMPEG Builder: Video Max Bitrate", + "Description": "Sets FFMPEG Builder limit the bitrate of video", + "Outputs": { + "1": "FFMPEG Builder video streams updated" + }, + "Fields": { + "Bitrate": "Maximum Bitrate", + "Bitrate-Suffix": "KB", + "Bitrate-Help": "The maximum bitrate of the video in kilobytes" + } + }, "FfmpegBuilderVideoCodec": { "Label": "FFMPEG Builder: Video Codec", "Description": "Sets FFMPEG Builder to encode the video streams in the specified codec",