mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-25 12:44:46 +01:00
Add video res to ffmpeg info
This commit is contained in:
parent
0c28e8a0ec
commit
6a3ddce7dd
@ -4,12 +4,17 @@ using System.Diagnostics;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
namespace Nikse.SubtitleEdit.Core.Common
|
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; }
|
||||||
|
|
||||||
|
private static readonly Regex ResolutionRegex = new Regex(@"\d\d+x\d\d+", RegexOptions.Compiled);
|
||||||
|
|
||||||
private FfmpegMediaInfo()
|
private FfmpegMediaInfo()
|
||||||
{
|
{
|
||||||
@ -56,6 +61,20 @@ namespace Nikse.SubtitleEdit.Core.Common
|
|||||||
var s = line.Trim();
|
var s = line.Trim();
|
||||||
if (s.StartsWith("Stream #", StringComparison.Ordinal))
|
if (s.StartsWith("Stream #", StringComparison.Ordinal))
|
||||||
{
|
{
|
||||||
|
var resolutionMatch = ResolutionRegex.Match(s);
|
||||||
|
if (resolutionMatch.Success)
|
||||||
|
{
|
||||||
|
var parts = resolutionMatch.Value.Split('x');
|
||||||
|
if (info.VideoWidth == 0 &&
|
||||||
|
parts.Length == 2 &&
|
||||||
|
int.TryParse(parts[0], out var w) &&
|
||||||
|
int.TryParse(parts[0], out var h))
|
||||||
|
{
|
||||||
|
info.VideoWidth = w;
|
||||||
|
info.VideoHeight = h;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var arr = s.Replace(": ", "¤").Split('¤');
|
var arr = s.Replace(": ", "¤").Split('¤');
|
||||||
if (arr.Length == 3)
|
if (arr.Length == 3)
|
||||||
{
|
{
|
||||||
@ -123,7 +142,7 @@ namespace Nikse.SubtitleEdit.Core.Common
|
|||||||
StartInfo =
|
StartInfo =
|
||||||
{
|
{
|
||||||
FileName = ffmpegLocation,
|
FileName = ffmpegLocation,
|
||||||
Arguments = $"-i \"{inputFileName}\" - hide_banner",
|
Arguments = $"-i \"{inputFileName}\" -hide_banner",
|
||||||
UseShellExecute = false,
|
UseShellExecute = false,
|
||||||
CreateNoWindow = true
|
CreateNoWindow = true
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user