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:
Ivandro Jao 2024-04-30 12:35:28 +01:00
parent f256b59691
commit 3e1fabac30

View File

@ -11,8 +11,8 @@ namespace Nikse.SubtitleEdit.Core.Common
public class FfmpegMediaInfo
{
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);
@ -65,13 +65,12 @@ namespace Nikse.SubtitleEdit.Core.Common
if (resolutionMatch.Success)
{
var parts = resolutionMatch.Value.Split('x');
if (info.VideoWidth == 0 &&
if (info.Dimension.Width == 0 &&
parts.Length == 2 &&
int.TryParse(parts[0], out var w) &&
int.TryParse(parts[1], out var h))
{
info.VideoWidth = w;
info.VideoHeight = h;
info.Dimension = new Dimension(h, w);
}
}