TIEMediaFoundationSourceReader
Declaration
TIEMediaFoundationSourceReader = class;
Description
Encapsulates Microsoft Media Foundation source reader object, allowing the capture of video and audio samples from a source.
Presently TIEMediaFoundationSourceReader can capture from video capture devices (webcams), files (all formats supported by Windows Media Player) and URLs.
To setup
TIEMediaFoundationSourceReader, applications must specify a video/file source, a video/audio stream and a media type. Then call GetNextSample() to read samples (images) from the source.
TImageEnView and
TImageEnIO embed a TIEMediaFoundationSourceReader object to simplify usage.
TIEMediaFoundationSourceReader is available in Windows Vista and newer.
Overview
| Demos\VideoCapture\MediaFoundationCam\MediaFoundationCam.dpr |
| Demos\VideoCapture\MediaFoundationFile\MediaFoundationFile.dpr |
| Demos\VideoCapture\MediaFoundationURL\MediaFoundationURL.dpr |
// 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(mmf_VIDEO_STREAM, 0); // select first media type of the first video stream
ImageEnView1.IO.MediaFoundationSourceReader.StartCapture(); // start capture
// handler for TImageEnView.OnMediaFoundatioNotify event
procedure TForm1.ImageEnView1MediaFoundationNotify(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;
Media Foundation AvailabilityEvents/Frame NotificationVideo Input InformationInput SelectionStream InformationStream SelectionMedia Type InformationMedia Type Selection (for native media type selection)Media Type Setting (for custom media types)Current Media Type InfoSeekingCapture ControlSample CaptureVideo Processing