예제 #1
0
        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);
        }
예제 #2
0
 public void Parse(string text, PixelFormat type)
 {
     Assert.Equal(type, PixelFormatHelper.Parse(text));
 }