Beispiel #1
0
        public static FFmpegStream Create([NotNull] AVStream *pStream, [NotNull] FFmpegMedia media)
        {
            if (pStream == null)
            {
                throw new ArgumentNullException(nameof(pStream));
            }
            if (media == null)
            {
                throw new ArgumentNullException(nameof(media));
            }

            FFmpegStream result;
            var          pCodec = pStream->codec;

            switch (pCodec->codec_type)
            {
            case AVMediaType.AVMEDIA_TYPE_AUDIO:
                result = new AudioStream(pStream, media);
                break;

            case AVMediaType.AVMEDIA_TYPE_VIDEO:
                result = new VideoStream(pStream, media);
                break;

            case AVMediaType.AVMEDIA_TYPE_SUBTITLE:
                result = new SubtitleStream(pStream, media);
                break;

            default:
                return(null);
            }
            return(result);
        }
Beispiel #2
0
        public AudioStream([NotNull] AVStream *pStream, [NotNull] FFmpegMedia media)
            : base(pStream, media)
        {
            var pCodec = pStream->codec;

            ChannelCount = pCodec->channels;
            SampleRate   = pCodec->sample_rate;
        }
Beispiel #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FFmpegStream"/> class.
 /// </summary>
 protected FFmpegStream([NotNull] AVStream *pStream, FFmpegMedia media)
 {
     if (pStream == null)
     {
         throw new ArgumentNullException(nameof(pStream));
     }
     AVStream = pStream;
     Codec    = pStream->codec->codec_id;
     Media    = media;
     Index    = pStream->index;
     Metadata = FFmpegUtils.ToDictionary(pStream->metadata);
 }
Beispiel #4
0
        public VideoStream([NotNull] AVStream *pStream, [NotNull] FFmpegMedia media)
            : base(pStream, media)
        {
            var pCodec         = pStream->codec;
            var framerateRatio = pCodec->framerate;

            FPS           = Convert.ToDouble(framerateRatio.num) / Convert.ToDouble(framerateRatio.den);
            FrameDuration = TimeSpan.FromTicks(TimeSpan.TicksPerSecond / Convert.ToInt64(FPS));
            PixelFormat   = pCodec->pix_fmt;
            Height        = pCodec->height;
            Width         = pCodec->width;
        }
Beispiel #5
0
 public SubtitleStream([NotNull] AVStream *pStream, [NotNull] FFmpegMedia media)
     : base(pStream, media)
 {
 }