ImageEn, unit imageenio

TImageEnIO.MediaFoundationSourceReader

TImageEnIO.MediaFoundationSourceReader


Declaration

property MediaFoundationSourceReader: TIEMediaFoundationSourceReader;


Description

MediaFoundationSourceReader is a TIEMediaFoundationSourceReader instance which allows capture samples from webcams, multimedia files and URLs.

This is a minimal setup to capture from a webcam (the first webcam, using first proposed media type):


ImageEnView1.IO.MediaFoundationSourceReader.SetVideoInput(0); // select first video input (first webcam)
ImageEnView1.IO.MediaFoundationSourceReader.SetSelectedStreams('Video', true); // enable first video stream
ImageEnView1.IO.MediaFoundationSourceReader.SelectMediaType('Video', 0); // select first media type of the first video stream
ImageEnView1.IO.MediaFoundationSourceReader.StartCapture(); // start capture

// handler for TImageEnView.OnMediaFoundatioNotify event
procedure TForm1.ImageEnVect1MediaFoundationNotify(Sender, MediaFoundationObject: TObject; NotifyType: TIEMediaFountationNotifyType);
var
  sample: TIEMFReceivedSample;
begin
  if NotifyType = iemfnFRAME then // is this a frame?
  begin
    sample := ImageEnView1.IO.MediaFoundationSourceReader.GetNextSample(); // retrieve frame sample
    try
      sample.DecodeSample(ImageEnView1.IEBitmap); // convert frame sample to bitmap
      ImageEnView1.Update(); // update TImageEnView to show the new bitmap
    finally
      sample.Free(); // free the sample
    end;
  end;
end;



Demos

Demo  Demos\VideoCapture\MediaFoundationCam\MediaFoundationCam.dpr
Demo  Demos\VideoCapture\MediaFoundationFile\MediaFoundationFile.dpr
Demo  Demos\VideoCapture\MediaFoundationURL\MediaFoundationURL.dpr