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