示例#1
0
 public ImageSource GetFrameByIndex(int index)
 {
     if (index < _videoFileReader.FrameCount && _videoFileReader.IsOpen)
     {
         Bitmap      videoFrame  = _videoFileReader.ReadVideoFrame(index);
         FrameParser parser      = new FrameParser();
         ImageSource imageSource = parser.ImageSourceForBitmap(videoFrame);
         imageSource.Freeze();
         return(imageSource);
     }
     else
     {
         return(null);
     }
 }
示例#2
0
        public List <ImageSource> GetFramesFromVideo(string fileName)
        {
            VideoFileReader reader = new VideoFileReader();

            reader.Open(fileName);

            FrameParser        parser      = new FrameParser();
            List <ImageSource> videoFrames = new List <ImageSource>();

            for (int i = 0; i < reader.FrameCount; i++)
            {
                Bitmap      videoFrame  = reader.ReadVideoFrame();
                ImageSource imageSource = parser.ImageSourceForBitmap(videoFrame);
                imageSource.Freeze();
                videoFrames.Add(imageSource);
                videoFrame.Dispose();
            }

            reader.Close();
            reader.Dispose();

            return(videoFrames);
        }