IMFSample interface (mfobjects.h)

Represents a media sample, which is a container object for media data. For video, a sample typically contains one video frame. For audio data, a sample typically contains multiple audio samples, rather than a single sample of audio.

A media sample contains zero or more buffers. Each buffer manages a block of memory, and is represented by the IMFMediaBuffer interface. A sample can have multiple buffers. The buffers are kept in an ordered list and accessed by index value. It is also valid to have an empty sample with no buffers.


The IMFSample interface inherits from IMFAttributes. IMFSample also has these types of members:


The IMFSample interface has these methods.


Adds a buffer to the end of the list of buffers in the sample.

Converts a sample with multiple buffers into a sample with a single buffer.

Copies the sample data to a buffer. This method concatenates the valid data from all of the buffers of the sample, in order.

Gets a buffer from the sample, by index.

Retrieves the number of buffers in the sample.

Retrieves the duration of the sample.

Retrieves flags associated with the sample.Currently no flags are defined.

Retrieves the presentation time of the sample.

Retrieves the total length of the valid data in all of the buffers in the sample. The length is calculated as the sum of the values retrieved by the IMFMediaBuffer::GetCurrentLength method.

Removes all of the buffers from the sample.

Removes a buffer at a specified index from the sample.

Sets the duration of the sample.

Sets flags associated with the sample.Currently no flags are defined.

Sets the presentation time of the sample.


To create a new media sample, call MFCreateSample.


When you call CopyAllItems, inherited from the IMFAttributes interface, on an IMFSample, the sample time, duration, and flags are not copied to the destination sample. You must copy these values to the new sample manually.

This interface is available on the following platforms if the Windows Media Format 11 SDK redistributable components are installed:
  • Windows XP with Service Pack 2 (SP2) and later.
  • Windows XP Media Center Edition 2005 with KB900325 (Windows XP Media Center Edition 2005) and KB925766 (October 2006 Update Rollup for Windows XP Media Center Edition) installed.


Requirement Value
Minimum supported client Windows Vista [desktop apps | UWP apps]
Minimum supported server Windows Server 2008 [desktop apps | UWP apps]
Target Platform Windows
Header mfobjects.h (include Mfidl.h)

See also


Media Foundation Interfaces

Media Samples

Sample Attributes