/// <summary> /// Initializes a new instance of the <see cref="VideoStream"/> class. /// </summary> /// <param name="video">The video stream.</param> /// <param name="options">The decoder settings.</param> internal VideoStream(InputStream <VideoFrame> video, MediaOptions options) { stream = video; mediaOptions = options; frame = VideoFrame.CreateEmpty(); scaler = new Scaler(); }
/// <summary> /// Initializes a new instance of the <see cref="VideoStream"/> class. /// </summary> /// <param name="video">The video stream.</param> /// <param name="options">The decoder settings.</param> internal VideoStream(InputStream <VideoFrame> video, MediaOptions options) { stream = video; mediaOptions = options; frame = VideoFrame.CreateEmpty(); converter = new ImageConverter(); }
/// <summary> /// Initializes a new instance of the <see cref="VideoStream"/> class. /// </summary> /// <param name="video">The video stream.</param> /// <param name="options">The decoder settings.</param> internal VideoStream(Decoder <VideoFrame> video, MediaOptions options) { stream = video; mediaOptions = options; frame = VideoFrame.CreateEmpty(); outputFrameSize = options.TargetVideoSize ?? video.Info.FrameSize; converter = new Lazy <ImageConverter>(() => new ImageConverter(video.Info.FrameSize, video.Info.AVPixelFormat, outputFrameSize, (AVPixelFormat)options.VideoPixelFormat)); }
/// <summary> /// Seeks stream to the specified target timestamp. /// </summary> /// <param name="targetTs">The target timestamp in the default stream time base.</param> public void SeekFile(long targetTs) { ffmpeg.av_seek_frame(Pointer, Video.Info.Index, targetTs, ffmpeg.AVSEEK_FLAG_BACKWARD).ThrowIfError($"Seek to {targetTs} failed."); IsAtEndOfFile = false; Video.PacketQueue.Clear(); Video.FlushBuffers(); AddPacket(MediaType.Video); AdjustSeekPackets(Video, targetTs, VideoFrame.CreateEmpty()); }
/// <summary> /// Seeks stream by skipping next packets in the file. Useful to seek few frames forward. /// </summary> /// <param name="targetTs">The target timestamp in the default stream time base.</param> public void SeekForward(long targetTs) => AdjustSeekPackets(Video, targetTs, VideoFrame.CreateEmpty());