예제 #1
0
        private AudioStream GenerateAudioStream(BaseStream baseStream, CoreStream coreStream)
        {
            AudioStream audioStream = new AudioStream(baseStream);

            audioStream.Profile       = coreStream.Profile;
            audioStream.Channels      = coreStream.Channels;
            audioStream.ChannelLayout = coreStream.ChannelLayout;
            audioStream.SampleFmt     = coreStream.SampleFmt;
            audioStream.SampleRate    = coreStream.SampleRate;
            audioStream.BitsPerSample = coreStream.BitsPerSample;

            return(audioStream);
        }
예제 #2
0
        private VideoStream GenerateVideoStream(BaseStream baseStream, CoreStream coreStream)
        {
            VideoStream videoStream = new VideoStream(baseStream);

            videoStream.Width              = coreStream.Width;
            videoStream.Height             = coreStream.Height;
            videoStream.CodedWidth         = coreStream.CodedWidth;
            videoStream.CodedHeight        = coreStream.CodedHeight;
            videoStream.Profile            = coreStream.Profile;
            videoStream.HasBFrames         = coreStream.HasBFrames;
            videoStream.PixFmt             = coreStream.PixFmt;
            videoStream.Level              = coreStream.Level;
            videoStream.Refs               = coreStream.Refs;
            videoStream.IsAvc              = coreStream.IsAvc;
            videoStream.NalLengthSize      = coreStream.NalLengthSize;
            videoStream.BitsPerRawSample   = coreStream.BitsPerRawSample;
            videoStream.FieldOrder         = coreStream.FieldOrder;
            videoStream.SampleAspectRatio  = ParseRatio(coreStream.SampleAspectRatio);
            videoStream.DisplayAspectRatio = ParseRatio(coreStream.DisplayAspectRatio);
            videoStream.RealFrameRate      = ParseRational(coreStream.RealFrameRate);
            videoStream.AverageFrameRate   = ParseRational(coreStream.AverageFrameRate);


            if (coreStream.ChromaLocation == null)
            {
                videoStream.ChromaLocation = TwoDimensionalOrientation.None;
                Console.WriteLine("Warning: StreamType NULL and not detected!");
            }
            else
            {
                switch (coreStream.ChromaLocation.ToLower())
                {
                case "left":
                    videoStream.ChromaLocation = TwoDimensionalOrientation.Left;
                    break;

                case "right":
                    videoStream.ChromaLocation = TwoDimensionalOrientation.Right;
                    break;

                default:
                    videoStream.ChromaLocation = TwoDimensionalOrientation.None;
                    Console.WriteLine("Warning: StreamType not detected! Given value: " + coreStream.ChromaLocation.ToLower());
                    break;
                }
            }

            return(videoStream);
        }
예제 #3
0
 public void WriteCore(object value)
 {
     CoreStream.Write(value);
 }
예제 #4
0
        private BaseStream GenerateBaseStream(CoreStream coreStream)
        {
            BaseStream baseStream = new BaseStream();

            baseStream.Index       = coreStream.Index;
            baseStream.StartPts    = coreStream.StartPts;
            baseStream.Disposition = coreStream.Disposition;
            baseStream.Tags        = coreStream.Tags;
            baseStream.TimeBase    = coreStream.TimeBase;
            baseStream.StartTime   = ParseTimeSpan(coreStream.StartTime);

            if (coreStream.StreamType == null)
            {
                baseStream.StreamType = StreamType.None;
                Console.WriteLine("ERROR: StreamType NULL and not detected!");
            }
            else
            {
                switch (coreStream.StreamType.ToLower())
                {
                case "video":
                    baseStream.StreamType = StreamType.Video;
                    break;

                case "audio":
                    baseStream.StreamType = StreamType.Audio;
                    break;

                case "subtitle":
                    baseStream.StreamType = StreamType.Subtitle;
                    break;

                case "data":
                    baseStream.StreamType = StreamType.Data;
                    break;

                case "attachment":
                    baseStream.StreamType = StreamType.Attachment;
                    break;

                default:
                    baseStream.StreamType = StreamType.None;
                    Console.WriteLine("ERROR: StreamType not detected! Given value: " + coreStream.StreamType.ToLower());
                    break;
                }
            }


            if (coreStream.Tags != null && coreStream.Tags.Any())
            {
                if (coreStream.Tags.ContainsKey("language"))
                {
                    baseStream.Language = coreStream.Tags
                                          .FirstOrDefault(x => x.Key.Equals("language", StringComparison.OrdinalIgnoreCase)).Value;
                }
            }

            Codec codec = new Codec();

            codec.TimeBase   = coreStream.CodecTimeBase;
            codec.Name       = coreStream.CodecName;
            codec.NameLong   = coreStream.CodecNameLong;
            codec.Tag        = coreStream.CodecTag;
            codec.TagString  = coreStream.CodecTagString;
            baseStream.Codec = codec;

            return(baseStream);
        }