Merge pull request #240 from GuyWithDogs/gwd_addcodectagstring

Added CodecTag and CodecTagString properties to FFProbeStream
This commit is contained in:
Malte Rosenbjerg 2021-08-10 10:24:40 +02:00 committed by GitHub
commit 1d845e889a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 0 deletions

View file

@ -63,6 +63,8 @@ public void Probe_Success()
Assert.AreEqual("LC", info.PrimaryAudioStream.Profile); Assert.AreEqual("LC", info.PrimaryAudioStream.Profile);
Assert.AreEqual(377351, info.PrimaryAudioStream.BitRate); Assert.AreEqual(377351, info.PrimaryAudioStream.BitRate);
Assert.AreEqual(48000, info.PrimaryAudioStream.SampleRateHz); Assert.AreEqual(48000, info.PrimaryAudioStream.SampleRateHz);
Assert.AreEqual("mp4a", info.PrimaryAudioStream.CodecTagString);
Assert.AreEqual("0x6134706d", info.PrimaryAudioStream.CodecTag);
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);
@ -76,6 +78,8 @@ public void Probe_Success()
Assert.AreEqual("h264", info.PrimaryVideoStream.CodecName); Assert.AreEqual("h264", info.PrimaryVideoStream.CodecName);
Assert.AreEqual(8, info.PrimaryVideoStream.BitsPerRawSample); Assert.AreEqual(8, info.PrimaryVideoStream.BitsPerRawSample);
Assert.AreEqual("Main", info.PrimaryVideoStream.Profile); Assert.AreEqual("Main", info.PrimaryVideoStream.Profile);
Assert.AreEqual("avc1", info.PrimaryVideoStream.CodecTagString);
Assert.AreEqual("0x31637661", info.PrimaryVideoStream.CodecTag);
} }
[TestMethod, Timeout(10000)] [TestMethod, Timeout(10000)]

View file

@ -41,6 +41,12 @@ public class FFProbeStream : ITagsContainer
[JsonPropertyName("codec_long_name")] [JsonPropertyName("codec_long_name")]
public string CodecLongName { get; set; } = null!; public string CodecLongName { get; set; } = null!;
[JsonPropertyName("codec_tag")]
public string CodecTag { get; set; } = null!;
[JsonPropertyName("codec_tag_string")]
public string CodecTagString { get; set; } = null!;
[JsonPropertyName("display_aspect_ratio")] [JsonPropertyName("display_aspect_ratio")]
public string DisplayAspectRatio { get; set; } = null!; public string DisplayAspectRatio { get; set; } = null!;

View file

@ -56,6 +56,8 @@ private VideoStream ParseVideoStream(FFProbeStream stream)
BitsPerRawSample = !string.IsNullOrEmpty(stream.BitsPerRawSample) ? MediaAnalysisUtils.ParseIntInvariant(stream.BitsPerRawSample) : default, BitsPerRawSample = !string.IsNullOrEmpty(stream.BitsPerRawSample) ? MediaAnalysisUtils.ParseIntInvariant(stream.BitsPerRawSample) : default,
CodecName = stream.CodecName, CodecName = stream.CodecName,
CodecLongName = stream.CodecLongName, CodecLongName = stream.CodecLongName,
CodecTag = stream.CodecTag,
CodecTagString = stream.CodecTagString,
DisplayAspectRatio = MediaAnalysisUtils.ParseRatioInt(stream.DisplayAspectRatio, ':'), DisplayAspectRatio = MediaAnalysisUtils.ParseRatioInt(stream.DisplayAspectRatio, ':'),
Duration = MediaAnalysisUtils.ParseDuration(stream), Duration = MediaAnalysisUtils.ParseDuration(stream),
FrameRate = MediaAnalysisUtils.DivideRatio(MediaAnalysisUtils.ParseRatioDouble(stream.FrameRate, '/')), FrameRate = MediaAnalysisUtils.DivideRatio(MediaAnalysisUtils.ParseRatioDouble(stream.FrameRate, '/')),
@ -77,6 +79,8 @@ private AudioStream ParseAudioStream(FFProbeStream stream)
BitRate = !string.IsNullOrEmpty(stream.BitRate) ? MediaAnalysisUtils.ParseIntInvariant(stream.BitRate) : default, BitRate = !string.IsNullOrEmpty(stream.BitRate) ? MediaAnalysisUtils.ParseIntInvariant(stream.BitRate) : default,
CodecName = stream.CodecName, CodecName = stream.CodecName,
CodecLongName = stream.CodecLongName, CodecLongName = stream.CodecLongName,
CodecTag = stream.CodecTag,
CodecTagString = stream.CodecTagString,
Channels = stream.Channels ?? default, Channels = stream.Channels ?? default,
ChannelLayout = stream.ChannelLayout, ChannelLayout = stream.ChannelLayout,
Duration = MediaAnalysisUtils.ParseDuration(stream), Duration = MediaAnalysisUtils.ParseDuration(stream),

View file

@ -10,6 +10,8 @@ public class MediaStream
public int Index { get; internal set; } public int Index { get; internal set; }
public string CodecName { get; internal set; } = null!; public string CodecName { get; internal set; } = null!;
public string CodecLongName { get; internal set; } = null!; public string CodecLongName { get; internal set; } = null!;
public string CodecTagString { get; set; } = null!;
public string CodecTag { get; set; } = null!;
public int BitRate { get; internal set; } public int BitRate { get; internal set; }
public TimeSpan Duration { get; internal set; } public TimeSpan Duration { get; internal set; }
public string? Language { get; internal set; } public string? Language { get; internal set; }