-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathClipInfo.cs
51 lines (43 loc) · 1.6 KB
/
ClipInfo.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
namespace BlinkClipsMerger
{
/// <summary>
/// Storing details on a clip.
/// </summary>
/// <param name="fullPath">The full path to clip file.</param>
/// <param name="captureTime">The capture time based on file name.</param>
internal class ClipInfo(string fullPath, DateTime captureTime)
{
public string FullPath { get; set; } = fullPath;
public DateTime CaptureTime { get; set; } = captureTime;
public bool HasAudio { get; set; }
public double Duration { get; set; }
public int ClipWidth { get; set; }
public int ClipHeight { get; set; }
public string FrameRate { get; set; }
/// <summary>
/// Parse the ffprobe frame rate to decimal.
/// Such as "30000/1001" to 29.97
/// </summary>
public double CalculatedFrameRate
{
get
{
if (!string.IsNullOrEmpty(this.FrameRate))
{
int slash = this.FrameRate.IndexOf('/');
if (slash > 0
&& int.TryParse(this.FrameRate[..slash], out int top)
&& int.TryParse(this.FrameRate[(slash + 1)..], out int bottom))
{
return 1d * top / bottom;
}
}
return double.NaN;
}
}
public override string ToString()
{
return $"au={(this.HasAudio ? 'y' : 'n')},di={this.ClipWidth}x{this.ClipHeight},fr={this.CalculatedFrameRate:0.00}fps,ln={this.Duration:0.00}s";
}
}
}