public MediaStreamInfo ToStreamInfo() { MediaStreamInfo stream = null; if (CodecType == "audio") { stream = new AudioStreamInfo { ChannelLayout = this.ChannelLayout, ChannelCount = this.ChannelCount, SampleFormat = FfmpegHelper.ParseSampleFormat(SampleFormat), SampleRate = SampleRate, }; } else if (CodecType == "video") { stream = new VideoStreamInfo { PixelFormat = PixelFormatHelper.Parse(PixelFormat), Width = this.Width, Height = this.Height }; if (Tags != null && Tags.TryGetValue("rotate", out var rotate)) { ((VideoStreamInfo)stream).Rotate = (int)rotate; } } else if (CodecType == "subtitle") { stream = new SubtitleStreamInfo { }; } else if (CodecType == "data") { stream = new DataStreamInfo { }; } else { stream = new MediaStreamInfo(); } stream.Codec = Profile != null?CodecInfo.Create(CodecIdHelper.Parse(CodecName), Profile).Name : CodecName; if (TimeBase != null && Rational.TryParse(TimeBase, out var timeBase)) { stream.TimeBase = timeBase; } stream.Duration = Duration ?? TimeSpan.Zero; stream.StartTime = StartTime ?? TimeSpan.Zero; stream.FrameCount = FrameCount; return(stream); }
public static CodecInfo Parse(string name) { if (name is null) { throw new ArgumentNullException(nameof(name)); } switch (name.ToUpper()) { // H264 Profiles case "AVC1.42E01E": return(H264Baseline); case "AVC1.4D401E": return(H264Main); case "AVC1.58A01E": return(H264Extended); case "AVC1.64001E": return(H264High); case "MP4V.20.9": return(H264Level0Simple); case "MP4V.20.240": return(H264Level0Advanced); case "MP3": return(Mp3); case "OPUS": return(Opus); case "VP8": return(Vp8); case "VP9": return(Vp9); // AAC Profiles case "AAC": return(Aac); case "MP4A.40.2": return(AacLC); case "MP4A.40.5": return(AacHE); } var id = CodecIdHelper.Parse(name); return(new CodecInfo(id)); }
public void ParseTests(string name, CodecId id) { Assert.Equal(id, CodecIdHelper.Parse(name)); }