Former-commit-id: 4ec200528c
This commit is contained in:
Malte Rosenbjerg 2023-02-04 23:42:13 +01:00 committed by GitHub
parent 737eea3a98
commit 3837edee8c
5 changed files with 13 additions and 4 deletions

View file

@ -84,7 +84,7 @@ public void MediaAnalysis_ParseDuration(string duration, int expectedDays, int e
{ {
var ffprobeStream = new FFProbeStream { Duration = duration }; var ffprobeStream = new FFProbeStream { Duration = duration };
var parsedDuration = MediaAnalysisUtils.ParseDuration(ffprobeStream); var parsedDuration = MediaAnalysisUtils.ParseDuration(ffprobeStream.Duration);
Assert.AreEqual(expectedDays, parsedDuration.Days); Assert.AreEqual(expectedDays, parsedDuration.Days);
Assert.AreEqual(expectedHours, parsedDuration.Hours); Assert.AreEqual(expectedHours, parsedDuration.Hours);

View file

@ -59,6 +59,9 @@ public class FFProbeStream : ITagsContainer, IDispositionContainer
[JsonPropertyName("sample_aspect_ratio")] [JsonPropertyName("sample_aspect_ratio")]
public string SampleAspectRatio { get; set; } = null!; public string SampleAspectRatio { get; set; } = null!;
[JsonPropertyName("start_time")]
public string StartTime { get; set; } = null!;
[JsonPropertyName("duration")] [JsonPropertyName("duration")]
public string Duration { get; set; } = null!; public string Duration { get; set; } = null!;

View file

@ -18,6 +18,7 @@ private MediaFormat ParseFormat(Format analysisFormat)
return new MediaFormat return new MediaFormat
{ {
Duration = MediaAnalysisUtils.ParseDuration(analysisFormat.Duration), Duration = MediaAnalysisUtils.ParseDuration(analysisFormat.Duration),
StartTime = MediaAnalysisUtils.ParseDuration(analysisFormat.StartTime),
FormatName = analysisFormat.FormatName, FormatName = analysisFormat.FormatName,
FormatLongName = analysisFormat.FormatLongName, FormatLongName = analysisFormat.FormatLongName,
StreamCount = analysisFormat.NbStreams, StreamCount = analysisFormat.NbStreams,
@ -66,7 +67,8 @@ private VideoStream ParseVideoStream(FFProbeStream stream)
CodecTagString = stream.CodecTagString, CodecTagString = stream.CodecTagString,
DisplayAspectRatio = MediaAnalysisUtils.ParseRatioInt(stream.DisplayAspectRatio, ':'), DisplayAspectRatio = MediaAnalysisUtils.ParseRatioInt(stream.DisplayAspectRatio, ':'),
SampleAspectRatio = MediaAnalysisUtils.ParseRatioInt(stream.SampleAspectRatio, ':'), SampleAspectRatio = MediaAnalysisUtils.ParseRatioInt(stream.SampleAspectRatio, ':'),
Duration = MediaAnalysisUtils.ParseDuration(stream), Duration = MediaAnalysisUtils.ParseDuration(stream.Duration),
StartTime = MediaAnalysisUtils.ParseDuration(stream.StartTime),
FrameRate = MediaAnalysisUtils.DivideRatio(MediaAnalysisUtils.ParseRatioDouble(stream.FrameRate, '/')), FrameRate = MediaAnalysisUtils.DivideRatio(MediaAnalysisUtils.ParseRatioDouble(stream.FrameRate, '/')),
Height = stream.Height ?? 0, Height = stream.Height ?? 0,
Width = stream.Width ?? 0, Width = stream.Width ?? 0,
@ -92,7 +94,8 @@ private AudioStream ParseAudioStream(FFProbeStream stream)
CodecTagString = stream.CodecTagString, 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.Duration),
StartTime = MediaAnalysisUtils.ParseDuration(stream.StartTime),
SampleRateHz = !string.IsNullOrEmpty(stream.SampleRate) ? MediaAnalysisUtils.ParseIntInvariant(stream.SampleRate) : default, SampleRateHz = !string.IsNullOrEmpty(stream.SampleRate) ? MediaAnalysisUtils.ParseIntInvariant(stream.SampleRate) : default,
Profile = stream.Profile, Profile = stream.Profile,
Language = stream.GetLanguage(), Language = stream.GetLanguage(),
@ -110,7 +113,8 @@ private SubtitleStream ParseSubtitleStream(FFProbeStream stream)
BitRate = !string.IsNullOrEmpty(stream.BitRate) ? MediaAnalysisUtils.ParseLongInvariant(stream.BitRate) : default, BitRate = !string.IsNullOrEmpty(stream.BitRate) ? MediaAnalysisUtils.ParseLongInvariant(stream.BitRate) : default,
CodecName = stream.CodecName, CodecName = stream.CodecName,
CodecLongName = stream.CodecLongName, CodecLongName = stream.CodecLongName,
Duration = MediaAnalysisUtils.ParseDuration(stream), Duration = MediaAnalysisUtils.ParseDuration(stream.Duration),
StartTime = MediaAnalysisUtils.ParseDuration(stream.StartTime),
Language = stream.GetLanguage(), Language = stream.GetLanguage(),
Disposition = MediaAnalysisUtils.FormatDisposition(stream.Disposition), Disposition = MediaAnalysisUtils.FormatDisposition(stream.Disposition),
Tags = stream.Tags.ToCaseInsensitive(), Tags = stream.Tags.ToCaseInsensitive(),

View file

@ -3,6 +3,7 @@
public class MediaFormat public class MediaFormat
{ {
public TimeSpan Duration { get; set; } public TimeSpan Duration { get; set; }
public TimeSpan StartTime { get; set; }
public string FormatName { get; set; } = null!; public string FormatName { get; set; } = null!;
public string FormatLongName { get; set; } = null!; public string FormatLongName { get; set; } = null!;
public int StreamCount { get; set; } public int StreamCount { get; set; }

View file

@ -10,6 +10,7 @@ public abstract class MediaStream
public string CodecTagString { get; set; } = null!; public string CodecTagString { get; set; } = null!;
public string CodecTag { get; set; } = null!; public string CodecTag { get; set; } = null!;
public long BitRate { get; set; } public long BitRate { get; set; }
public TimeSpan StartTime { get; set; }
public TimeSpan Duration { get; set; } public TimeSpan Duration { get; set; }
public string? Language { get; set; } public string? Language { get; set; }
public Dictionary<string, bool>? Disposition { get; set; } public Dictionary<string, bool>? Disposition { get; set; }