mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-21 18:52:36 +01:00
Add FramesRate to FfmpegMediaInfo
This commit is contained in:
parent
0dcb118064
commit
c522cdaef3
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@ -14,9 +15,12 @@ namespace Nikse.SubtitleEdit.Core.Common
|
||||
|
||||
public Dimension Dimension { get; set; }
|
||||
public TimeCode Duration { get; set; }
|
||||
public decimal FramesRate { get; set; }
|
||||
|
||||
private static readonly Regex ResolutionRegex = new Regex(@"\d\d+x\d\d+", RegexOptions.Compiled);
|
||||
private static readonly Regex DurationRegex = new Regex(@"Duration: \d+[:\.,]\d+[:\.,]\d+[:\.,]\d+", RegexOptions.Compiled);
|
||||
private static readonly Regex Fps1Regex = new Regex(@" \d+\.\d+ fps", RegexOptions.Compiled);
|
||||
private static readonly Regex Fps2Regex = new Regex(@" \d+ fps", RegexOptions.Compiled);
|
||||
|
||||
private FfmpegMediaInfo()
|
||||
{
|
||||
@ -58,6 +62,20 @@ namespace Nikse.SubtitleEdit.Core.Common
|
||||
{
|
||||
var info = new FfmpegMediaInfo();
|
||||
|
||||
var fpsMatch = Fps1Regex.Match(log);
|
||||
if (!fpsMatch.Success)
|
||||
{
|
||||
fpsMatch = Fps2Regex.Match(log);
|
||||
}
|
||||
if (fpsMatch.Success)
|
||||
{
|
||||
var fps = fpsMatch.Value.Trim().Split(' ')[0];
|
||||
if (double.TryParse(fps, NumberStyles.Any, CultureInfo.InvariantCulture, out var f))
|
||||
{
|
||||
info.FramesRate = (decimal)f;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var line in log.SplitToLines())
|
||||
{
|
||||
var s = line.Trim();
|
||||
|
Loading…
Reference in New Issue
Block a user