fixed issue with video info parsing timestamps

attempting to fix issue with encoding videos on docker
This commit is contained in:
reven
2021-12-12 10:49:41 +13:00
parent d74aec8c1e
commit 27a3e78110
11 changed files with 93 additions and 10 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+47
View File
@@ -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<string> Messages = new List<string>();
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
+26
View File
@@ -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
+2 -2
View File
@@ -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)
Binary file not shown.
+15 -5
View File
@@ -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;
}
}
}
+3 -3
View File
@@ -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"
}
]