private void UpdateFrame() { _currentFrameIndex = Math.Max(0, Math.Min(_frameHeaders.Length - 1, _currentFrameIndex)); FrameIndexTextBlock.Text = $"{_currentFrameIndex + 1}/{_frameHeaders.Length}"; if (_frameHeaders.IsEmpty()) { return; } var header = _frameHeaders[_currentFrameIndex]; IVideoFrame frame; using (var stream = new FileStream(_dataFilePrefix + VideoFramesFileWriter.FileSuffix, FileMode.Open)) { stream.Position = header.Position; frame = VideoFrameRecord.Read(stream, header.Index).Frame; } VideoFrameImage.Source = frame.ToBitmap().ToBitmapSource(); FrameIndexTextBlock.Text = $"{_currentFrameIndex + 1}/{_frameHeaders.Length} ({frame.Width}×{frame.Height}, T:{header.Timestamp})"; }
private static VideoFrameHeader[] LoadVideoFrameHeaders(string dataFilePrefix) { var file = dataFilePrefix + VideoFramesFileWriter.FileSuffix; if (!File.Exists(file)) { return(EmptyArray <VideoFrameHeader> .Instance); } var videoFrameRecords = new LinkedList <VideoFrameHeader>(); uint index = 0; using (var fileStream = new FileStream(file, FileMode.Open)) while (fileStream.Position < fileStream.Length) { var pos = fileStream.Position; var timestamp = VideoFrameRecord.ReadTimestampAndSkip(fileStream); videoFrameRecords.AddLast(new VideoFrameHeader(pos, index++, timestamp)); } return(videoFrameRecords.OrderByTimestamp().ToArray()); }