mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-25 12:44:46 +01:00
Refactor FfmpegMediaInfo to use Dimension for dimensions
The properties VideoWidth and VideoHeight in FfmpegMediaInfo class have been replaced with a Dimension object. This modification leads to simpler and more readable code by encapsulating width and height information within the Dimension class. Any resolution information extracted is now directly assigned to the Dimension property. Signed-off-by: Ivandro Jao <ivandrofly@gmail.com>
This commit is contained in:
parent
f256b59691
commit
3e1fabac30
@ -11,8 +11,8 @@ namespace Nikse.SubtitleEdit.Core.Common
|
|||||||
public class FfmpegMediaInfo
|
public class FfmpegMediaInfo
|
||||||
{
|
{
|
||||||
public List<FfmpegTrackInfo> Tracks { get; set; }
|
public List<FfmpegTrackInfo> Tracks { get; set; }
|
||||||
public int VideoWidth { get; set; }
|
|
||||||
public int VideoHeight { get; set; }
|
public Dimension Dimension { get; set; }
|
||||||
|
|
||||||
private static readonly Regex ResolutionRegex = new Regex(@"\d\d+x\d\d+", RegexOptions.Compiled);
|
private static readonly Regex ResolutionRegex = new Regex(@"\d\d+x\d\d+", RegexOptions.Compiled);
|
||||||
|
|
||||||
@ -65,13 +65,12 @@ namespace Nikse.SubtitleEdit.Core.Common
|
|||||||
if (resolutionMatch.Success)
|
if (resolutionMatch.Success)
|
||||||
{
|
{
|
||||||
var parts = resolutionMatch.Value.Split('x');
|
var parts = resolutionMatch.Value.Split('x');
|
||||||
if (info.VideoWidth == 0 &&
|
if (info.Dimension.Width == 0 &&
|
||||||
parts.Length == 2 &&
|
parts.Length == 2 &&
|
||||||
int.TryParse(parts[0], out var w) &&
|
int.TryParse(parts[0], out var w) &&
|
||||||
int.TryParse(parts[1], out var h))
|
int.TryParse(parts[1], out var h))
|
||||||
{
|
{
|
||||||
info.VideoWidth = w;
|
info.Dimension = new Dimension(h, w);
|
||||||
info.VideoHeight = h;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user