mirror of
https://github.com/n00mkrad/flowframes.git
synced 2025-12-24 04:09:29 +01:00
Full VFR handling including FPS downsampling to CFR
This commit is contained in:
@@ -24,7 +24,7 @@ namespace Flowframes.Data
|
||||
public string Format;
|
||||
public string Title;
|
||||
public string Language;
|
||||
public Fraction? InputRate = null;
|
||||
public Fraction InputRate;
|
||||
public long DurationMs;
|
||||
public int StreamCount;
|
||||
public int TotalKbits;
|
||||
@@ -42,6 +42,8 @@ namespace Flowframes.Data
|
||||
public bool IsVfr = false;
|
||||
public List<float> InputTimestamps = new List<float>();
|
||||
public List<float> InputTimestampDurations = new List<float>();
|
||||
public List<float> OutputTimestamps = new List<float>();
|
||||
public List<int> OutputFrameIndexes = null;
|
||||
|
||||
public int FileCount = 1;
|
||||
public int FrameCount { get { return VideoStreams.Count > 0 ? VideoStreams[0].FrameCount : 0; } }
|
||||
@@ -140,35 +142,6 @@ namespace Flowframes.Data
|
||||
TotalKbits = (await GetVideoInfo.GetFfprobeInfoAsync(path, GetVideoInfo.FfprobeMode.ShowFormat, "bit_rate")).GetInt() / 1000;
|
||||
}
|
||||
|
||||
public List<float> GetResampledTimestamps(List<float> timestamps, double factor)
|
||||
{
|
||||
int originalCount = timestamps.Count;
|
||||
int newCount = (int)Math.Round(originalCount * factor);
|
||||
List<float> resampledTimestamps = new List<float>();
|
||||
|
||||
for (int i = 0; i < newCount; i++)
|
||||
{
|
||||
double x = i / factor;
|
||||
|
||||
if (x >= originalCount - 1)
|
||||
{
|
||||
resampledTimestamps.Add(timestamps[originalCount - 1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
int index = (int)Math.Floor(x);
|
||||
double fraction = x - index;
|
||||
float startTime = timestamps[index];
|
||||
float endTime = timestamps[index + 1];
|
||||
|
||||
float interpolatedTime = (float)(startTime + (endTime - startTime) * fraction);
|
||||
resampledTimestamps.Add(interpolatedTime);
|
||||
}
|
||||
}
|
||||
|
||||
return resampledTimestamps;
|
||||
}
|
||||
|
||||
public string GetName()
|
||||
{
|
||||
if (IsDirectory)
|
||||
|
||||
Reference in New Issue
Block a user