update VideoEncode to only force audio reencode if container changes

This commit is contained in:
reven
2021-12-12 11:05:34 +13:00
parent 27a3e78110
commit 84617fca6b
10 changed files with 13 additions and 14 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VideoNodes
namespace FileFlows.VideoNodes
{
internal static class ExtensionMethods
{
@@ -12,7 +6,11 @@ namespace VideoNodes
if (dict.ContainsKey(key))
dict[key] = value;
else
dict.Add(key, value);
dict.Add(key, value);
}
public static string? EmptyAsNull(this string str)
{
return str == string.Empty ? null : str;
}
}
}

Binary file not shown.

View File

@@ -51,7 +51,7 @@ namespace FileFlows.VideoNodes
VideoCodecParameters = args.ReplaceVariables(VideoCodecParameters);
AudioCodec = args.ReplaceVariables(AudioCodec);
Language = args.ReplaceVariables(Language);
Extension = args.ReplaceVariables(Extension);
Extension = args.ReplaceVariables(Extension)?.EmptyAsNull() ?? "mkv";
VideoCodec = VideoCodec.ToLower();
AudioCodec = AudioCodec.ToLower();
@@ -92,6 +92,8 @@ namespace FileFlows.VideoNodes
bool audioRightCodec = bestAudio?.Codec?.ToLower() == AudioCodec && videoInfo.AudioStreams[0] == bestAudio;
args.Logger?.ILog("Best Audio: ", bestAudio == null ? "null" : (object)bestAudio);
bool sameContainer = new FileInfo(args.WorkingFile).Extension.ToLower() == Extension.ToLower();
string crop = args.GetParameter<string>(DetectBlackBars.CROP_KEY) ?? "";
if (crop != string.Empty)
@@ -123,7 +125,7 @@ namespace FileFlows.VideoNodes
TotalTime = videoInfo.VideoStreams[0].Duration;
if (audioRightCodec == false || videoIsRightCodec == null) // always redo audio if video is wrong codec, as this can lead to some failed encodes (found in mp4s to mkvs)
if (audioRightCodec == false || sameContainer == false) // if container changes, re-encode audio, otherwise this can lead to failed encodings (mp4 to mkv this can happen... a lot)
ffArgs.Add($"-map 0:{bestAudio!.Index} -c:a {AudioCodec}");
else
ffArgs.Add($"-map 0:{bestAudio!.Index} -c:a copy");

View File

@@ -1,7 +1,6 @@
namespace FileFlows.VideoNodes
{
using FileFlows.Plugin;
using global::VideoNodes;
public abstract class VideoNode : Node
{

View File

@@ -1,17 +1,17 @@
[
{
"Name": "BasicNodes",
"Version": "0.0.1.26",
"Version": "0.0.1.27",
"Package": "https://github.com/revenz/FileFlowsPlugins/blob/master/Builds/BasicNodes.zip?raw=true"
},
{
"Name": "MetaNodes",
"Version": "0.0.1.26",
"Version": "0.0.1.27",
"Package": "https://github.com/revenz/FileFlowsPlugins/blob/master/Builds/MetaNodes.zip?raw=true"
},
{
"Name": "VideoNodes",
"Version": "0.0.1.26",
"Version": "0.0.1.27",
"Package": "https://github.com/revenz/FileFlowsPlugins/blob/master/Builds/VideoNodes.zip?raw=true"
}
]