mirror of
https://github.com/rosenbjerg/FFMpegCore.git
synced 2024-11-10 08:34:12 +01:00
Add SampleAspectRatio property to VideoStream
Former-commit-id: 02de377093
This commit is contained in:
parent
2344f4868e
commit
1dd2685aff
4 changed files with 39 additions and 32 deletions
|
@ -1,10 +1,10 @@
|
||||||
using System;
|
using FFMpegCore.Test.Resources;
|
||||||
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using FFMpegCore.Test.Resources;
|
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
||||||
|
|
||||||
namespace FFMpegCore.Test
|
namespace FFMpegCore.Test
|
||||||
{
|
{
|
||||||
|
@ -74,9 +74,9 @@ public void PacketAnalysisAudioVideo_Sync()
|
||||||
|
|
||||||
Assert.AreEqual(216, packets.Count);
|
Assert.AreEqual(216, packets.Count);
|
||||||
var actual = packets.Select(f => f.CodecType).Distinct().ToList();
|
var actual = packets.Select(f => f.CodecType).Distinct().ToList();
|
||||||
var expected = new List<string> {"audio", "video"};
|
var expected = new List<string> { "audio", "video" };
|
||||||
CollectionAssert.AreEquivalent(expected, actual);
|
CollectionAssert.AreEquivalent(expected, actual);
|
||||||
Assert.IsTrue(packets.Where(t=>t.CodecType == "audio").All(f => f.Flags == "K_"));
|
Assert.IsTrue(packets.Where(t => t.CodecType == "audio").All(f => f.Flags == "K_"));
|
||||||
Assert.AreEqual(75, packets.Count(t => t.CodecType == "video"));
|
Assert.AreEqual(75, packets.Count(t => t.CodecType == "video"));
|
||||||
Assert.AreEqual(141, packets.Count(t => t.CodecType == "audio"));
|
Assert.AreEqual(141, packets.Count(t => t.CodecType == "audio"));
|
||||||
}
|
}
|
||||||
|
@ -125,6 +125,8 @@ public void Probe_Success()
|
||||||
Assert.AreEqual(1471810, info.PrimaryVideoStream!.BitRate);
|
Assert.AreEqual(1471810, info.PrimaryVideoStream!.BitRate);
|
||||||
Assert.AreEqual(16, info.PrimaryVideoStream.DisplayAspectRatio.Width);
|
Assert.AreEqual(16, info.PrimaryVideoStream.DisplayAspectRatio.Width);
|
||||||
Assert.AreEqual(9, info.PrimaryVideoStream.DisplayAspectRatio.Height);
|
Assert.AreEqual(9, info.PrimaryVideoStream.DisplayAspectRatio.Height);
|
||||||
|
Assert.AreEqual(1, info.PrimaryVideoStream.SampleAspectRatio.Width);
|
||||||
|
Assert.AreEqual(1, info.PrimaryVideoStream.SampleAspectRatio.Height);
|
||||||
Assert.AreEqual("yuv420p", info.PrimaryVideoStream.PixelFormat);
|
Assert.AreEqual("yuv420p", info.PrimaryVideoStream.PixelFormat);
|
||||||
Assert.AreEqual(1280, info.PrimaryVideoStream.Width);
|
Assert.AreEqual(1280, info.PrimaryVideoStream.Width);
|
||||||
Assert.AreEqual(720, info.PrimaryVideoStream.Height);
|
Assert.AreEqual(720, info.PrimaryVideoStream.Height);
|
||||||
|
|
|
@ -53,6 +53,9 @@ public class FFProbeStream : ITagsContainer, IDispositionContainer
|
||||||
[JsonPropertyName("display_aspect_ratio")]
|
[JsonPropertyName("display_aspect_ratio")]
|
||||||
public string DisplayAspectRatio { get; set; } = null!;
|
public string DisplayAspectRatio { get; set; } = null!;
|
||||||
|
|
||||||
|
[JsonPropertyName("sample_aspect_ratio")]
|
||||||
|
public string SampleAspectRatio { get; set; } = null!;
|
||||||
|
|
||||||
[JsonPropertyName("duration")]
|
[JsonPropertyName("duration")]
|
||||||
public string Duration { get; set; } = null!;
|
public string Duration { get; set; } = null!;
|
||||||
|
|
||||||
|
|
|
@ -61,6 +61,7 @@ private VideoStream ParseVideoStream(FFProbeStream stream)
|
||||||
CodecTag = stream.CodecTag,
|
CodecTag = stream.CodecTag,
|
||||||
CodecTagString = stream.CodecTagString,
|
CodecTagString = stream.CodecTagString,
|
||||||
DisplayAspectRatio = MediaAnalysisUtils.ParseRatioInt(stream.DisplayAspectRatio, ':'),
|
DisplayAspectRatio = MediaAnalysisUtils.ParseRatioInt(stream.DisplayAspectRatio, ':'),
|
||||||
|
SampleAspectRatio = MediaAnalysisUtils.ParseRatioInt(stream.SampleAspectRatio, ':'),
|
||||||
Duration = MediaAnalysisUtils.ParseDuration(stream),
|
Duration = MediaAnalysisUtils.ParseDuration(stream),
|
||||||
FrameRate = MediaAnalysisUtils.DivideRatio(MediaAnalysisUtils.ParseRatioDouble(stream.FrameRate, '/')),
|
FrameRate = MediaAnalysisUtils.DivideRatio(MediaAnalysisUtils.ParseRatioDouble(stream.FrameRate, '/')),
|
||||||
Height = stream.Height ?? 0,
|
Height = stream.Height ?? 0,
|
||||||
|
|
|
@ -7,6 +7,7 @@ public class VideoStream : MediaStream
|
||||||
public double AvgFrameRate { get; set; }
|
public double AvgFrameRate { get; set; }
|
||||||
public int BitsPerRawSample { get; set; }
|
public int BitsPerRawSample { get; set; }
|
||||||
public (int Width, int Height) DisplayAspectRatio { get; set; }
|
public (int Width, int Height) DisplayAspectRatio { get; set; }
|
||||||
|
public (int Width, int Height) SampleAspectRatio { get; set; }
|
||||||
public string Profile { get; set; } = null!;
|
public string Profile { get; set; } = null!;
|
||||||
public int Width { get; set; }
|
public int Width { get; set; }
|
||||||
public int Height { get; set; }
|
public int Height { get; set; }
|
||||||
|
|
Loading…
Reference in a new issue