0xC00D4A44 MF_E_SINK_NO_SAMPLES_PROCESSED with MPEG 4 sink

1

I am running out of ideas on why I am getting this HRESULT.

I have a pipeline in Media Foundation. A file is loaded through the source resolver. I am using the media session.

Here is my general pipeline:

Source Reader -> Decoder -> Color Converter (to RGB24) -> Custom MFT -> Color Converter (To YUY2) -> H264 Encoder -> Mpeg 4 Sink

In my custom MFT I do some editing to the frames. One of the tasks of the MFT is to filter samples and drop the undesired ones.

This pipeline is used to trim video and output an MP4 file.

For example if the user wants to trim 3 seconds from the 10 second marker, my MFT will read the uncompressed sample time and discard it by asking for more samples. If a sample is in range, it will be passed to the next color converter. My MFT handles frames in RGB24, hence the reason for the initial color converter. The second color converter transforms the color space for the H264 encoder. I am using the High Profile Level 4.1 encoder.

The pipeline gets setup properly. All of the frames get passed to the sink and I have a wrapper for the MPEG4 sink. I see that the BeginFinalize and EndFinalize gets called.

However on some of my trim operations, the EndFinalize with spit out the MF_E_SINK_NO_SAMPLES_PROCESSED. I think it is random. It usually happens when a range not close to the beginning is selected.

It might be due to sample times. I am rebasing the sample times and duration.

For example, if the adjusted frame duration is 50ms (selected by user), I will grab the first acceptable sample (let's say 1500ms) and rebase it to 0. The next one will be 1550ms in my MFT and then set to 50ms and so on. So frame times are set in 50ms increments.

Is this approach correct? Could it be that the sink is not receiving enough samples to write the headers and finalize the file?

As mentioned, it work in some cases and it fails in most. I am running my code on Windows 10.

video-processing
ms-media-foundation
mpeg-4
asked on Stack Overflow Mar 25, 2017 by KevinSP • edited Mar 25, 2017 by KevinSP

1 Answer

1

I tried to implement the same task using IMFMediaSession/IMFtopology, but had the same problems you faced. I think that IMFMediaSession either modifies the timestamps outside your MFT, or expects them not to be modified by your MFT. So in order to make this work, I took the IMFSourceReader->IMFSinkWriter approach. This way I could modify the timestmaps of the samples read from the reader and pass to the writer only those that fall into the given range. Furthermore, you can take a look at the old MFCopy example. It does exactly the file trimming as you described it. You can download it from here: https://sourceforge.net/projects/mfnode/

answered on Stack Overflow Mar 26, 2017 by VuVirt

User contributions licensed under CC BY-SA 3.0