mirror of
https://github.com/rosenbjerg/FFMpegCore.git
synced 2024-11-10 08:34:12 +01:00
parent
2601dc3a83
commit
bd7dcf9edd
3 changed files with 27 additions and 3 deletions
|
@ -9,7 +9,9 @@ public interface IMediaAnalysis
|
||||||
MediaFormat Format { get; }
|
MediaFormat Format { get; }
|
||||||
AudioStream? PrimaryAudioStream { get; }
|
AudioStream? PrimaryAudioStream { get; }
|
||||||
VideoStream? PrimaryVideoStream { get; }
|
VideoStream? PrimaryVideoStream { get; }
|
||||||
|
SubtitleStream? PrimarySubtitleStream { get; }
|
||||||
List<VideoStream> VideoStreams { get; }
|
List<VideoStream> VideoStreams { get; }
|
||||||
List<AudioStream> AudioStreams { get; }
|
List<AudioStream> AudioStreams { get; }
|
||||||
|
List<SubtitleStream> SubtitleStreams { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,8 +12,9 @@ internal MediaAnalysis(FFProbeAnalysis analysis)
|
||||||
Format = ParseFormat(analysis.Format);
|
Format = ParseFormat(analysis.Format);
|
||||||
VideoStreams = analysis.Streams.Where(stream => stream.CodecType == "video").Select(ParseVideoStream).ToList();
|
VideoStreams = analysis.Streams.Where(stream => stream.CodecType == "video").Select(ParseVideoStream).ToList();
|
||||||
AudioStreams = analysis.Streams.Where(stream => stream.CodecType == "audio").Select(ParseAudioStream).ToList();
|
AudioStreams = analysis.Streams.Where(stream => stream.CodecType == "audio").Select(ParseAudioStream).ToList();
|
||||||
|
SubtitleStreams = analysis.Streams.Where(stream => stream.CodecType == "subtitle").Select(ParseSubtitleStream).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private MediaFormat ParseFormat(Format analysisFormat)
|
private MediaFormat ParseFormat(Format analysisFormat)
|
||||||
{
|
{
|
||||||
return new MediaFormat
|
return new MediaFormat
|
||||||
|
@ -36,12 +37,14 @@ private MediaFormat ParseFormat(Format analysisFormat)
|
||||||
}.Max();
|
}.Max();
|
||||||
|
|
||||||
public MediaFormat Format { get; }
|
public MediaFormat Format { get; }
|
||||||
|
|
||||||
public AudioStream? PrimaryAudioStream => AudioStreams.OrderBy(stream => stream.Index).FirstOrDefault();
|
public AudioStream? PrimaryAudioStream => AudioStreams.OrderBy(stream => stream.Index).FirstOrDefault();
|
||||||
|
|
||||||
public VideoStream? PrimaryVideoStream => VideoStreams.OrderBy(stream => stream.Index).FirstOrDefault();
|
public VideoStream? PrimaryVideoStream => VideoStreams.OrderBy(stream => stream.Index).FirstOrDefault();
|
||||||
|
public SubtitleStream? PrimarySubtitleStream => SubtitleStreams.OrderBy(stream => stream.Index).FirstOrDefault();
|
||||||
|
|
||||||
public List<VideoStream> VideoStreams { get; }
|
public List<VideoStream> VideoStreams { get; }
|
||||||
public List<AudioStream> AudioStreams { get; }
|
public List<AudioStream> AudioStreams { get; }
|
||||||
|
public List<SubtitleStream> SubtitleStreams { get; }
|
||||||
|
|
||||||
private VideoStream ParseVideoStream(FFProbeStream stream)
|
private VideoStream ParseVideoStream(FFProbeStream stream)
|
||||||
{
|
{
|
||||||
|
@ -84,7 +87,19 @@ private AudioStream ParseAudioStream(FFProbeStream stream)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private SubtitleStream ParseSubtitleStream(FFProbeStream stream)
|
||||||
|
{
|
||||||
|
return new SubtitleStream
|
||||||
|
{
|
||||||
|
Index = stream.Index,
|
||||||
|
BitRate = !string.IsNullOrEmpty(stream.BitRate) ? MediaAnalysisUtils.ParseIntInvariant(stream.BitRate) : default,
|
||||||
|
CodecName = stream.CodecName,
|
||||||
|
CodecLongName = stream.CodecLongName,
|
||||||
|
Duration = MediaAnalysisUtils.ParseDuration(stream),
|
||||||
|
Language = stream.GetLanguage(),
|
||||||
|
Tags = stream.Tags,
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class MediaAnalysisUtils
|
public static class MediaAnalysisUtils
|
||||||
|
|
7
FFMpegCore/FFProbe/SubtitleStream.cs
Normal file
7
FFMpegCore/FFProbe/SubtitleStream.cs
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
namespace FFMpegCore
|
||||||
|
{
|
||||||
|
public class SubtitleStream : MediaStream
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue