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); }
public AudioStream([NotNull] AVStream *pStream, [NotNull] FFmpegMedia media) : base(pStream, media) { var pCodec = pStream->codec; ChannelCount = pCodec->channels; SampleRate = pCodec->sample_rate; }
/// <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); }
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; }
public SubtitleStream([NotNull] AVStream *pStream, [NotNull] FFmpegMedia media) : base(pStream, media) { }