go ahead and merge in part 1 if you have to.
This commit is contained in:
parent
d55458eaa4
commit
6b9d44b286
44
Program.cs
44
Program.cs
@ -36,28 +36,27 @@ namespace videoRetailor
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var afterFirst = mediaInfos.Skip(1).ToList();
|
foreach (var thisMeta in mediaInfos)
|
||||||
foreach (var thisMeta in afterFirst)
|
|
||||||
{
|
{
|
||||||
totalTime += thisMeta.ffprobed[0].Duration;
|
totalTime += thisMeta.ffprobed[0].Duration;
|
||||||
}
|
}
|
||||||
var averageTime = totalTime.TotalSeconds / afterFirst.Count();
|
var averageTime = totalTime.TotalSeconds / mediaInfos.Count();
|
||||||
Console.WriteLine($"average time: {averageTime}");
|
Console.WriteLine($"average time: {averageTime}");
|
||||||
foreach (var thisMeta in afterFirst)
|
foreach (var thisMeta in mediaInfos)
|
||||||
{
|
{
|
||||||
thisMeta.durationVariance = thisMeta.TotalSeconds / averageTime;
|
thisMeta.durationVariance = thisMeta.TotalSeconds / averageTime;
|
||||||
Console.WriteLine($"{string.Join(", ", thisMeta.path)}: {thisMeta.TotalSeconds} seconds");
|
Console.WriteLine($"{string.Join(", ", thisMeta.path)}: {thisMeta.TotalSeconds} seconds");
|
||||||
Console.WriteLine($" duration ratio: {thisMeta.durationVariance}");
|
Console.WriteLine($" duration ratio: {thisMeta.durationVariance}");
|
||||||
}
|
}
|
||||||
Console.WriteLine($"...am I crashing? {afterFirst.Min(af => af.durationVariance)}");
|
Console.WriteLine($"...am I crashing? {mediaInfos.Min(af => af.durationVariance)}");
|
||||||
while (afterFirst.Count() > 6 &&
|
while (mediaInfos.Count() > 7 &&
|
||||||
(afterFirst.Min(af => af.durationVariance) < 0.9))
|
(mediaInfos.Min(af => af.durationVariance) < 0.9))
|
||||||
{
|
{
|
||||||
Console.WriteLine("gluestick at the ready.");
|
Console.WriteLine("gluestick at the ready.");
|
||||||
var idx = 0;
|
var idx = 0;
|
||||||
var targetMinDuration = afterFirst.Min(af => af.durationVariance);
|
var targetMinDuration = mediaInfos.Min(af => af.durationVariance);
|
||||||
Console.WriteLine($"targetMinDuration = {targetMinDuration}");
|
Console.WriteLine($"targetMinDuration = {targetMinDuration}");
|
||||||
foreach (var af in afterFirst)
|
foreach (var af in mediaInfos)
|
||||||
{
|
{
|
||||||
if (af.durationVariance == targetMinDuration)
|
if (af.durationVariance == targetMinDuration)
|
||||||
{
|
{
|
||||||
@ -65,33 +64,32 @@ namespace videoRetailor
|
|||||||
}
|
}
|
||||||
idx++;
|
idx++;
|
||||||
}
|
}
|
||||||
var previousDuration = (idx == 0) ? Double.MaxValue : afterFirst[idx - 1].TotalSeconds;
|
var previousDuration = (idx == 0) ? Double.MaxValue : mediaInfos[idx - 1].TotalSeconds;
|
||||||
var nextDuration = (idx > afterFirst.Count() - 2) ? Double.MaxValue : afterFirst[idx - 1].TotalSeconds;
|
var nextDuration = (idx > mediaInfos.Count() - 2) ? Double.MaxValue : mediaInfos[idx - 1].TotalSeconds;
|
||||||
analyzedMedia partner;
|
analyzedMedia partner;
|
||||||
if (nextDuration > previousDuration)
|
if (nextDuration > previousDuration)
|
||||||
{
|
{
|
||||||
partner = afterFirst[idx - 1];
|
partner = mediaInfos[idx - 1];
|
||||||
Console.WriteLine($"combining with previous, previously at {partner.TotalSeconds}");
|
Console.WriteLine($"combining with previous, previously at {partner.TotalSeconds}");
|
||||||
partner.ffprobed.AddRange(afterFirst[idx].ffprobed);
|
partner.ffprobed.AddRange(mediaInfos[idx].ffprobed);
|
||||||
partner.path.AddRange(afterFirst[idx].path);
|
partner.path.AddRange(mediaInfos[idx].path);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
partner = afterFirst[idx + 1];
|
partner = mediaInfos[idx + 1];
|
||||||
Console.WriteLine($"combining with next, previously at {partner.TotalSeconds}");
|
Console.WriteLine($"combining with next, previously at {partner.TotalSeconds}");
|
||||||
afterFirst[idx].ffprobed.AddRange(partner.ffprobed);
|
mediaInfos[idx].ffprobed.AddRange(partner.ffprobed);
|
||||||
partner.ffprobed = afterFirst[idx].ffprobed;
|
partner.ffprobed = mediaInfos[idx].ffprobed;
|
||||||
afterFirst[idx].path.AddRange(partner.path);
|
mediaInfos[idx].path.AddRange(partner.path);
|
||||||
partner.path = afterFirst[idx].path;
|
partner.path = mediaInfos[idx].path;
|
||||||
}
|
}
|
||||||
afterFirst.RemoveAt(idx);
|
mediaInfos.RemoveAt(idx);
|
||||||
averageTime = totalTime.TotalSeconds / afterFirst.Count();
|
averageTime = totalTime.TotalSeconds / mediaInfos.Count();
|
||||||
foreach (var thisMeta in afterFirst)
|
foreach (var thisMeta in mediaInfos)
|
||||||
{
|
{
|
||||||
thisMeta.durationVariance = thisMeta.TotalSeconds / averageTime;
|
thisMeta.durationVariance = thisMeta.TotalSeconds / averageTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mediaInfos = mediaInfos.Take(1).Union(afterFirst).ToList();
|
|
||||||
}
|
}
|
||||||
Console.WriteLine($"{mediaInfos.Count()} infos.");
|
Console.WriteLine($"{mediaInfos.Count()} infos.");
|
||||||
var i = 1;
|
var i = 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user