added option to VideoCodec node to only include first video stream in output

This commit is contained in:
John Andrews
2022-04-11 15:42:59 +12:00
parent ab681244d4
commit ddbb09de23
6 changed files with 16 additions and 5 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -15,6 +15,10 @@
[Boolean(3)]
public bool Force { get; set; }
[Boolean(4)]
[DefaultValue(true)]
public bool DisableOtherVideoStreams { get; set; }
public override int Execute(NodeParameters args)
{
base.Init(args);
@@ -28,15 +32,20 @@
parameters = CheckVideoCodec(ffmpegExe, parameters);
bool encoding = false;
foreach (var stream in Model.VideoStreams)
foreach (var item in Model.VideoStreams.Select((x, index) => (stream: x, index)))
{
if(DisableOtherVideoStreams && item.index > 0)
{
item.stream.Deleted = true;
continue;
}
if(Force == false)
{
if (IsSameVideoCodec(stream.Stream.Codec, this.VideoCodec))
if (IsSameVideoCodec(item.stream.Stream.Codec, this.VideoCodec))
continue;
}
stream.EncodingParameters.Clear();
stream.EncodingParameters.AddRange(SplitCommand(parameters));
item.stream.EncodingParameters.Clear();
item.stream.EncodingParameters.AddRange(SplitCommand(parameters));
encoding = true;
}
return encoding ? 1 : 2;

View File

@@ -275,7 +275,9 @@
"VideoCodecParameters": "Video Codec Parameters",
"VideoCodecParameters-Help": "The parameters to use to encode the video, eg. \"hevc_nvenc -preset hq -crf 23\" to encode into hevc using the HQ preset a constant rate factor of 23 and using NVIDIA hardware acceleration.",
"Force": "Force Encode",
"Force-Help": "Will force a encode of the video even if it is already in the target Video Codec"
"Force-Help": "Will force a encode of the video even if it is already in the target Video Codec",
"DisableOtherVideoStreams": "Only First",
"DisableOtherVideoStreams-Help": "When checked if there are multiple video streams in the file, this will remove all but the first video stream from the file once executed."
}
},
"RemuxToMKV": {