diff --git a/BasicNodes/BasicNodes.csproj b/BasicNodes/BasicNodes.csproj index 841793fd..805ad689 100644 Binary files a/BasicNodes/BasicNodes.csproj and b/BasicNodes/BasicNodes.csproj differ diff --git a/Builds/BasicNodes.zip b/Builds/BasicNodes.zip index 784f8e7c..e1d83390 100644 Binary files a/Builds/BasicNodes.zip and b/Builds/BasicNodes.zip differ diff --git a/Builds/MetaNodes.zip b/Builds/MetaNodes.zip index e7036b7f..a1468aa3 100644 Binary files a/Builds/MetaNodes.zip and b/Builds/MetaNodes.zip differ diff --git a/Builds/VideoNodes.zip b/Builds/VideoNodes.zip index 3383cc7a..581fe18d 100644 Binary files a/Builds/VideoNodes.zip and b/Builds/VideoNodes.zip differ diff --git a/MetaNodes/MetaNodes.csproj b/MetaNodes/MetaNodes.csproj index 8a338546..aae95b3a 100644 Binary files a/MetaNodes/MetaNodes.csproj and b/MetaNodes/MetaNodes.csproj differ diff --git a/VideoNodes/Tests/TestLogger.cs b/VideoNodes/Tests/TestLogger.cs new file mode 100644 index 00000000..3ab9564c --- /dev/null +++ b/VideoNodes/Tests/TestLogger.cs @@ -0,0 +1,47 @@ +#if(DEBUG) + +namespace VideoNodes.Tests +{ + using FileFlows.Plugin; + using System; + using System.Collections.Generic; + using System.Linq; + using System.Text; + using System.Threading.Tasks; + + internal class TestLogger : ILogger + { + private List Messages = new List(); + + public void DLog(params object[] args) => Log("DBUG", args); + + public void ELog(params object[] args) => Log("ERRR", args); + + public void ILog(params object[] args) => Log("INFO", args); + + public void WLog(params object[] args) => Log("WARN", args); + + private void Log(string type, object[] args) + { + if (args == null || args.Length == 0) + return; + string message = type + " -> " + + string.Join(", ", args.Select(x => + x == null ? "null" : + x.GetType().IsPrimitive || x is string ? x.ToString() : + System.Text.Json.JsonSerializer.Serialize(x))); + Messages.Add(message); + } + + public bool Contains(string message) + { + if (string.IsNullOrWhiteSpace(message)) + return false; + + string log = string.Join(Environment.NewLine, Messages); + return log.Contains(message); + } + } +} + +#endif \ No newline at end of file diff --git a/VideoNodes/Tests/VideoInfoHelperTests.cs b/VideoNodes/Tests/VideoInfoHelperTests.cs new file mode 100644 index 00000000..9029a0b2 --- /dev/null +++ b/VideoNodes/Tests/VideoInfoHelperTests.cs @@ -0,0 +1,26 @@ +#if(DEBUG) + +namespace VideoNodes.Tests +{ + using FileFlows.VideoNodes; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using System; + using System.Collections.Generic; + using System.Linq; + using System.Text; + using System.Threading.Tasks; + + [TestClass] + public class VideoInfoHelperTests + { + [TestMethod] + public void VideoInfoTest_JudgeDreed() + { + var vi = new VideoInfoHelper(@"C:\utils\ffmpeg\ffmpeg.exe", new TestLogger()); + vi.Read(@"D:\videos\unprocessed\Judge Dredd (1995)\Judge Dredd (1995) Bluray-1080p.mkv"); + + } + } +} + +#endif \ No newline at end of file diff --git a/VideoNodes/VideoInfoHelper.cs b/VideoNodes/VideoInfoHelper.cs index c5f57c77..e51737f6 100644 --- a/VideoNodes/VideoInfoHelper.cs +++ b/VideoNodes/VideoInfoHelper.cs @@ -11,8 +11,8 @@ namespace FileFlows.VideoNodes private ILogger Logger; Regex rgxTitle = new Regex(@"(?<=((^[\s]+title[\s]+:[\s])))(.*?)$", RegexOptions.Multiline); - Regex rgxDuration = new Regex(@"(?<=((^[\s]+DURATION(\-[\w]+)?[\s]+:[\s])))([\d]+:?)+\.[\d]+[1-9]", RegexOptions.Multiline); - Regex rgxDuration2 = new Regex(@"(?<=((^[\s]+Duration:[\s])))([\d]+:?)+\.[\d]+[1-9]", RegexOptions.Multiline); + Regex rgxDuration = new Regex(@"(?<=((^[\s]+DURATION(\-[\w]+)?[\s]+:[\s])))([\d]+:?)+\.[\d]{1,7}", RegexOptions.Multiline); + Regex rgxDuration2 = new Regex(@"(?<=((^[\s]+Duration:[\s])))([\d]+:?)+\.[\d]{1,7}", RegexOptions.Multiline); Regex rgxAudioSampleRate = new Regex(@"(?<=((,|\s)))[\d]+(?=([\s]?hz))", RegexOptions.IgnoreCase); public VideoInfoHelper(string ffMpegExe, ILogger logger) diff --git a/VideoNodes/VideoNodes.csproj b/VideoNodes/VideoNodes.csproj index e7ea7dd5..2c8d91fd 100644 Binary files a/VideoNodes/VideoNodes.csproj and b/VideoNodes/VideoNodes.csproj differ diff --git a/VideoNodes/VideoNodes/VideoEncode.cs b/VideoNodes/VideoNodes/VideoEncode.cs index 45521862..c5047ec5 100644 --- a/VideoNodes/VideoNodes/VideoEncode.cs +++ b/VideoNodes/VideoNodes/VideoEncode.cs @@ -123,15 +123,18 @@ namespace FileFlows.VideoNodes TotalTime = videoInfo.VideoStreams[0].Duration; - if (audioRightCodec == false) + 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) ffArgs.Add($"-map 0:{bestAudio!.Index} -c:a {AudioCodec}"); else ffArgs.Add($"-map 0:{bestAudio!.Index} -c:a copy"); - if (Language != string.Empty) - ffArgs.Add($"-map 0:s:m:language:{Language}? -c:s copy"); - else - ffArgs.Add($"-map 0:s? -c:s copy"); + if (SupportsSubtitles(Extension)) + { + if (Language != string.Empty) + ffArgs.Add($"-map 0:s:m:language:{Language}? -c:s copy"); + else + ffArgs.Add($"-map 0:s? -c:s copy"); + } string ffArgsLine = string.Join(" ", ffArgs); @@ -163,5 +166,12 @@ namespace FileFlows.VideoNodes return input; } } + + private bool SupportsSubtitles(string container) + { + if (Regex.IsMatch(container ?? string.Empty, "(mp(e)?(g)?4)|avi|divx|xvid", RegexOptions.IgnoreCase)) + return false; + return true; + } } } \ No newline at end of file diff --git a/plugins.json b/plugins.json index 76249e04..249433a1 100644 --- a/plugins.json +++ b/plugins.json @@ -1,17 +1,17 @@ [ { "Name": "BasicNodes", - "Version": "0.0.1.25", + "Version": "0.0.1.26", "Package": "https://github.com/revenz/FileFlowsPlugins/blob/master/Builds/BasicNodes.zip?raw=true" }, { "Name": "MetaNodes", - "Version": "0.0.1.25", + "Version": "0.0.1.26", "Package": "https://github.com/revenz/FileFlowsPlugins/blob/master/Builds/MetaNodes.zip?raw=true" }, { "Name": "VideoNodes", - "Version": "0.0.1.25", + "Version": "0.0.1.26", "Package": "https://github.com/revenz/FileFlowsPlugins/blob/master/Builds/VideoNodes.zip?raw=true" } ]