Quantcast
Channel: Media Foundation Development for Windows Desktop forum
Viewing all 1079 articles
Browse latest View live

IMFSinkWriter drops delta frames

$
0
0

We have a hardware capture card creating a VC1/Wmv stream that we feed into a Media Foundation topology. The stream is rendered just fine, but when writing to disk, using an IMFSinkWriter, sometimes delta frames are dropped resulting in smearing until next key frame. The sink writer does not have any encoder associated, the input and target media types are equal.

We are quite certain that this is caused by the sink writer deliberately dropping frames in order to keep the average bit rate within limits. If we set the video stream (in hardware) to approx 3 MBit/s, the same bitrate value is used as target media type in a call to AddStream on the sink writer. If the input stream (again created in hardware) is overshooting the target, we see dropped frames down in the writer.

If we (using the same 3Mbit/s stream) tell the sink writer we have a 6Mbit/s target media type, no frame drops seems to occur.

The big question is then: How can we prohibit the sink writer from dropping frames. We have set MF_MT_ALL_SAMPLES_INDEPENDENT to FALSE and we have tried changing the MF_SINK_WRITER_DISABLE_THROTTLING but this doesn't seem to help.

The follow up is: How can we detect if frame drop occurs? We can of course see it in the resulting file where samples are missing, but we don't seem to get any information from the sink writer. Even the IMFSinkWriter GetStatistics method reports all samples being processed. 

Could the frame drop be a buffer overflow issue? We have read about the leaky bucket buffering, but we havn't been able to configure these options on our sink writer (which is created using MFCreateSinkWriterFromURL). 

As a workaround, could someone describe the consequences of having a wmv file with an erroneous (too large) average bit rate information in its header?

Regards Björn


Bjorn


UVC Capture regression in 1803

$
0
0

Starting with Windows 10 build 1803, if an application captures from a UVC device (I'm using an AverMedia ExtremeCap UVC), then closes, then attempts to capture again the IMFMediaSourceActivate.Activate() method returns E_INVALIDARG. This behavior is reproducible using the MFCaptureD3D example code from the Windows 7 SDK. A workaround for the issue is to unplug and replug the device after the application closes.

I noticed this behavior started happening on two different machines with two different capture devices after the 1803 update.I say "possible" regression since I don't have any way to get a 1709 build to test on to verify this. (Incidentally, if anyone has an easy legal way to install previous builds of Windows 10 for application testing I would appreciate it)

Edit: I found a machine with 1709 still installed, and was able to verify that the issue is not present on that version.




HEVC Encoding to Main 4:4:4 Profile

$
0
0
Is it possible with MediaFoundation and the SinkWriter to encode HEVC video with 4:4:4 chroma sampling instead of the default 4:2:0? I've tried setting the output MediaType Mpeg2Profile to 6 (eAVEncH265VProfile_Main_444_8) but the resulting video is always in 4:2:0. I also can't seem to get proper 0-255 color range in the resulting video. Source content is RGB32. I also tried with the H.264 encoder (and appropriate eAVEncH264VProfile_Main_444_8 profile) but get the same results. Thanks for the help!

How is the EVR's video mixer ( VMR9 wrapped in an MFT ) handling the frame rate of a substream ?

$
0
0

Hi

I would like to know the exact behavior of Microsoft's Direct3D 9 aware Video Mixer MFT ( which can be created using theMFCreateVideoMixer function ) when it comes to handling the frame rate of a substream. This question is directed towards the developers of Microsoft as only they know the source code. I saw in another question here in the forum that Becky Weiss was able to contact Vlad who seem to be the guy who wrote the EVR. That gave me hope to write my question and maybe get an answer.

You might ask yourself why i would need to know such in depth detail of the mixer. Well, i developed a lot of Direct3D 11 aware MFTs and sources over the years and was just about to finish a Direct3D 11 Video Mixer, which is 100 % compatible with the EVR. To design a video mixer which is behaving exactly the same way as Microsoft's own i developed a test bench. That test app alone is 20k-30k lines of code. I would say nobody ever tested Microsoft's Video Mixer that deep. Even though i was able to find out almost evrything the mixer does, there is an important detail which cannot be resolved without reverse engineering. And since that is illegal, and because it is a DXVA / Direct3D 11 Video API thing anyway, i will ask the question here in the forum.

->

My observations of Microsoft's EVR mixer, about handling the frame rate of a substream, are the following :

1.

If a substream has a higher frame rate than the reference stream, then the frame rate gets downsampled with DXVA. That means theOutputFrameFreq member of the DXVA2_VideoDesc structure will be set to the frame rate of the reference stream. This is done in the SetInputType method of the MFT when setting a media type for a substream. If the video processing device is not offering frame rate conversion, then method will fail. 

2.

If a substream has a lower frame rate than the reference stream, then the frames are getting buffered in a list. The size of that list will be equal to the result of dividing the reference stream frame rate by the substream frame rate ( rounded value ). A frame will be taken for rendering from that buffer list according to the sample time and duration measured against the former substream sample and the current reference stream sample. That way the frames are getting passed in a correct way, as if the frame rate was upsampled, to the video processing device.

<-

There is plenty of DXVA documentation in the MSDN, even for frame rate conversion. But it is nowhere meantioned if downsampling and upsampling should be used the same way in DXVA / Direct3D 11 Video API. From my observation Microsoft's Video Mixer does not use upsamplig in DXVA at all. It just buffers and uses the substream samples according to the reference stream sample time.

The reason might be that the VMR9 mixer comes from an area where media coding wasnt very matured and most drivers either lacked frame rate conversion or did not offer a wide sprectrum of it. Of course this is just guessing and cannot be determined, there is also nothing about it in the MSDN.

My hope is that a developer from Microsoft could give me either an insight of the Video Mixer MFT or clarify how to handle the frame rate of a substream in DXVA / Direct3D 11 Video API.

Kindly regards,

Francis




Setting Rate above 2 on Session does not work since 1803

$
0
0

since the Creators Update 1803 setting the rate above 2 does not work anymore.

My application is a simple media player, which plays video with different rates.

On Windows 8 and 10 (<=1709) everything works fine, but since the Creators Update the application hangs and video stands still when setting rate above 2.

Calling IsFramerateSupported or Getfastest Rate returns that a rate is valid, but when setting the rate the player goes crazy.

Any suggestions?

MF built in H264 decoder resolution limitation in WES7

$
0
0

Hi,

We've recently stumbled upon the resolution limitation for h264 decoding in MediaFoundation in WES7 being set at 1920x1088. Using another machine running Windows 7 Professional with the latest updates shows that this limitation was removed but we are unable to update MediaFoundation on WES7 using the KB's that are available from Microsoft. Trying to install them results in an error message saying that the update is not applicable.

How can we update this system to a more recent version of MediaFoundation, one that doesn't have the built in h264 decoder limited to the 1920*1088 resolution?

We didn't have much success trying to find third party MFTs for h264 decoding that would go higher in accepted video resolution, so we kind of gave up that option. That being said, if anyone could suggest a third party codec for this purpose, it would also be greatly appreciated.

Thank you,

Ionut

Can IMFMediaEngineEx support output stereoscopic 3D video side by side?

$
0
0

Using following code, to play a stereoscopic 3D video

   ::MFStartup(MF_VERSION);
    CComPtr<IMFMediaEngineClassFactory> spCF;
    spCF.CoCreateInstance(CLSID_MFMediaEngineClassFactory);
    CComPtr<IMFAttributes> spAttr;
    ::MFCreateAttributes(&spAttr, 0);
    spAttr->SetUINT64(MF_MEDIA_ENGINE_PLAYBACK_HWND, (UINT64)hWnd/*(UINT64)GetSafeHwnd()*/);
    spAttr->SetUnknown(MF_MEDIA_ENGINE_CALLBACK, &nn);

    HRESULT  hr = spCF->CreateInstance(0, spAttr, &m_spEngine);
    m_spEngine->QueryInterface(__uuidof(IMFMediaEngineEx), (void**)&m_spEngineEx);
    m_spEngine->SetSource(CComBSTR(L"g:\\mdjsj3-sbs.mp4"));

    m_spEngine->Play();

I got only left or maybe right view,

but what I want is side by side view,

Can IMFMediaEngineEx support output MVC 3D video side by side?





Interpreting EMF spool file

$
0
0

I am developing remote printing driver through the use of EMF spool file. So
one machine (computer A) will generate EMF spool file and this file will be
printed on other (arbitrary) machine (computer B).

My questions are:
-how do I install specific font stored in EMF spool file on machine B ?
There are five different font types. I assume AddFontMemResourceEx should
work for EMRI_ENGINE_FONT and EMRI_TYPE1_FONT

but how do I install other three e.g. the EMRI_SUBSET_FONT

the documentation just mention: The EMRI_SUBSET_FONT record contains a subset of TrueType and OpenType fonts, which can be merged to form more complete fonts. An EMRI_SUBSET_FONT record defines enough glyph outlines for pages up to the current one.

which one record should be merge to the EMRI_SUBSET_FONT?

thanks


[UWP][C++] MFTrace not showing many calls when debugging

$
0
0

I'm using mftrace to debug a UWP app that uses Media Foundation. The problem however is, that many calls are not showing up in the log.

For example, I'm logging MFPlatExport which should hook all exported functions from mfplat.dll, right?

Well, functions like MFCreateDXGISurfaceBuffer, MFCreateVideoSampleAllocatorEx or MFCreateEventQueue never show up in the log, even if I trace at the highest level.

Am I doing something wrong or is the tool just too old for this?

What withelds Media Foundation from playing HLS streams above 1080p?

$
0
0
The HLS file I'm using supports resolutions from 360p, 480p, 720p, 1080p, 1440p and 4K but Media Foundation starts with one fragment of 360p and then only plays 1080p, it does not play 4K even though all 16, 1080p fragments are being downloaded within a second. I expected Media Foundation to choose the 4K video fragments because of the internet speed but apparently it doesn't. When I supply a .m3u8 playlist with only a 4K video it simply plays it like it should. What other factors take part in making Media Foundation decide which video quality to play? And how would I allow a higher quality video if clearly it should have no problem playing it?

MF_E_UNSUPPORTED_BYTESTREAM_TYPE on calling MFCreateSourceReaderFromURL for a mp3 decoder

$
0
0
Hi,

I’m developing an mp3 decoder using Media Foundation API.

Everything works fine in my pc and on all the computers I’ve tested, except for a PC with Windows 7 Home Premium, where the api

    IMFSourceReader * pReader = NULL;
    HRESULT hrError = MFCreateSourceReaderFromURL(<file_to_decode.mp3>, 0, &pReader);

fails with error MF_E_UNSUPPORTED_BYTESTREAM_TYPE.

The mp3 file is the same for all tests.

Am I missing something? Any idea?

IMFCaptureEngine Access Violation for MJPG Video format on Windows 8 32bit

$
0
0

I'm developing the desktop application to record .mp4 video format from USB camera using Capture Engine sample code. My application is crashing while recording the MJPG video format onWindows 8 32bit OS.

I have modified the capture engine sample code as per my requirement and completed the development. My application is working fine in the following OSes: Window 10 64bit, Window 8.1 32/64bit and Windows 8 64bit.

The USB camera supports two video formats: UYVY and MJPG. The Access violation occurs only when the camera has MJPG and  UYVY format. To verify the crash issue, I tried different cameras which have above formats and able to recreate the issue. 

Then, I tried the camera which supports YUY2 and MJPG format and my application are able to record a video in the two formats without any crash.

Also, I updated the PC and tried it but unfortunately, the issue still persists.

The issue is occurring after initializing the preview and retrieving the current media type usingGetCurrentDeviceMediaType(). Below code snippet is used to configure for video recording.

HRESULT RecordVideo(TCHAR *tzDestinationFile)
{
	HRESULT hr = E_FAIL;
	IMFCaptureSink *pCaptureSink = NULL;
	IMFCaptureRecordSink *pRecordSink = NULL;
	IMFCaptureSource *pCaptureSource = NULL;
	IMFMediaSource *pMediaSource = NULL;
	IMFPresentationDescriptor *pPD = NULL;
	IMFMediaType* pSrcMediaType = NULL;

	if((m_pCaptureEngine == NULL) || (m_pCaptureEngineCB == NULL))	{	return MF_E_NOT_INITIALIZED;	}

	hr = m_pCaptureEngine->GetSink(MF_CAPTURE_ENGINE_SINK_TYPE_RECORD, &pCaptureSink);	if (FAILED(hr)){	goto done;	}

	hr = pCaptureSink->QueryInterface(IID_PPV_ARGS(&pRecordSink));	if (FAILED(hr)){	goto done;	}

	hr = m_pCaptureEngine->GetSource(&pCaptureSource);	if (FAILED(hr)){	goto done;	}

	// Clear any existing streams from previous recordings.
	hr = pRecordSink->RemoveAllStreams();	if (FAILED(hr)){	goto done;	}

	hr = pRecordSink->SetOutputFileName(tzDestinationFile);		if (FAILED(hr)){	goto done;	}

	hr = ConfigureVideoEncoding(pCaptureSource, pRecordSink, MFVideoFormat_H264);	if (FAILED(hr)){	goto done;	}

	hr = m_pCaptureEngine->StartRecord();	if (FAILED(hr)){	goto done;	}

	m_bRecording = true;		
    
done:
    SafeRelease(&pCaptureSource);
    SafeRelease(&pRecordSink);
	SafeRelease(&pPD);
    SafeRelease(&pMediaSource);
    return hr;	
}



HRESULT ConfigureVideoEncoding(IMFCaptureSource *pCaptureSource, IMFCaptureRecordSink *pRecordSink, REFGUID guidEncodingType)
{
	IMFMediaType *pMediaType = NULL;
	IMFMediaType *pH264MediaType = NULL;
	GUID guidSubType = GUID_NULL;

	if((pCaptureSource == NULL) || (pRecordSink == NULL) || (guidEncodingType == GUID_NULL))
		return E_FAIL;

	// Configure the video format for the recording sink.
	HRESULT hr = pCaptureSource->GetCurrentDeviceMediaType((DWORD)MF_CAPTURE_ENGINE_PREFERRED_SOURCE_STREAM_FOR_VIDEO_RECORD , &pMediaType);	if (FAILED(hr)){	goto done;	}

	if(pMediaType == NULL)
		return E_FAIL;

	hr = ConfigureH264EncoderMediaType(pMediaType, guidEncodingType, &pH264MediaType);	if (FAILED(hr)){	goto done;	}

	// Connect the video stream to the recording sink.		
	DWORD dwSinkStreamIndex = 0;
	hr = pRecordSink->AddStream((DWORD)MF_CAPTURE_ENGINE_PREFERRED_SOURCE_STREAM_FOR_VIDEO_RECORD, pH264MediaType, NULL, &dwSinkStreamIndex);	if (FAILED(hr)){	goto done;	}

done:
    SafeRelease(&pMediaType);
    SafeRelease(&pH264MediaType);
    return hr;
}

In addition to that, I'm posting the access violation exception and my PC configuration here. I hope this will be helpful to find the root cause.

Exception:

First-chance exception at 0x75151A65 in .exe: Microsoft C++ exception: _com_error at memory location 0x0312F538.
First-chance exception at 0x75151A65 in .exe: Microsoft C++ exception: _com_error at memory location 0x0312F538.

..........OnCaptureEvent MF_CAPTURE_ENGINE_PREVIEW_STARTED

First-chance exception at 0x53D9FF4C (mfreadwrite.dll) in .exe: 0xC0000005: Access violation reading location 0x00000000.
Unhandled exception at 0x53D9FF4C (mfreadwrite.dll) in .exe: 0xC0000005: Access violation reading location 0x00000000.

DxDiag:

------------------
System Information
------------------
Time of this report: 5/9/2018, 18:17:57
       Machine name: WindowsTeam
   Operating System: Windows 8 Pro 32-bit (6.2, Build 9200) (9200.win8_gdr.151112-0600)
           Language: English (Regional Setting: English)
System Manufacturer: Dell Inc.
       System Model: Vostro 3900  
               BIOS: BIOS Date: 03/03/15 15:17:01 Ver: 04.06.05
          Processor: Intel(R) Core(TM) i5-4460  CPU @ 3.20GHz (4 CPUs), ~3.2GHz
             Memory: 4096MB RAM
Available OS Memory: 3502MB RAM
          Page File: 1139MB used, 3003MB available
        Windows Dir: C:\Windows
    DirectX Version: DirectX 11
DX Setup Parameters: Not found
   User DPI Setting: Using System DPI
 System DPI Setting: 96 DPI (100 percent)
    DWM DPI Scaling: Disabled
     DxDiag Version: 6.02.9200.16384 32bit Unicode

I investigated in many ways but I could not get any clue to solve this issue. I was stick with the issue for past one week. 

May I know why this issue is occurring only on Windows 8 32bit?

Let me know if you require any other information from my end.

Thanks in advance.


Does the Audio Resampler DSP realy need the caller to allocate the output sample ?

$
0
0

Hello

The Audio Resampler DSP does not give back any flags when calling GetOutputStreamInfo. If we go by the Documentation, then we can assume that we need to allocate the output sample right ?

My observation:

If i pass NULL with pSample in the MFT_OUTPUT_DATA_BUFFER structure, then i get a MF_E_TRANSFORM_NEED_MORE_INPUT ( poor choice of error code by the developer of that MFT but well … ) when calling ProcessOutput.

If i allocate a sample and pass it with pSample in the MFT_OUTPUT_DATA_BUFFER structure, then ProcessOutput succeeds.

So it definitly looks like we need to allocate the output samples for ProcessOutput. I would just like to get a confirmation here that the Audio Resampler DSP needs the caller to allocate the output sample.

Thanks



DirectDraw crash after CTL-ALT-DEL

$
0
0

Hello,

I'm developing a video player using DirectDraw on Windows 10.

When I run the application, it runs well without a problem. However if I press CTL-ALT-DEL and then return to previous

screen DirectDraw crashes after few (~10 seconds max?) seconds. The crash callstack seems like below:

 ddraw.dll!_TrimNotificationCallback@4() <---------------------- executing 0x00000000 

 gdi32.dll!DxTrimWnfCallback()

 ...

 ntdll.dll!__RtUserThreadStart@8()

Before getting this crash a BLT failure (and following surface lock failure) took place first. Releasing and recreating errortic

DD surface doesn't solve the problem.

Is there any way to fix or override this problem?

Thanks in advacne,

-SY


Does windows has similar technic like V4l2 Buffer Sharing?

$
0
0

V4l2 buffer sharing is processing video input without buffer copy on linux.

Does directshow/media foundation/d3d has similar technics?

https://www.freedesktop.org/wiki/Software/Beignet/howto/v4l2-buffer-sharing-howto/


Changing applications audio endpoint device

$
0
0

I'm not sure if this is the right place for this.. but I'm trying to figure out how to set the default endpoint programmatically for an application I'm writing.

There are applications like https://github.com/audiorouterdev/audio-router/tree/open/audio-router that do it externally on a per app bases but this seems like over kill. Not to mention part of the reason I'm doing this pet project is so I *don't* have to install 5 apps to create a sound board that routes to specific audio devices.. 

I know there are sound boards that do that already but I have some other use cases they don't fit and desire for more simplicity in the setup.

Output buffer as input

$
0
0
I am using the Video processor transform to scale a Texture I have.  This seems to work ok and I then wish to encode it using a transform.  At the moment I am taking the output from the video processor transform and passing it to the encoder transform.  Is this the correct way to do things?  At the moment I have no errors until I go to process output from the encoder which fails.

H264 video preview in windows using MFC in c++

$
0
0

I have a camera, which gives me H264 video format. I'm new to this video previewing in windows.

I would like to know how to preview H264 video format from the camera to an application in windows using Media Foundation or capture engine in c++?

Basic start would be more helpful. Explain me with some examples or links to get through it?

Thanks in Advance!

EVR: Minimal video decode overhead when video not visible.

$
0
0
Hi,
Trying to keep a video running even when not visible but want decode overhead minimal when it can't be seen.

From your sample EVR :

https://github.com/pauldotknopf/WindowsSDK7-Samples/blob/master/multimedia/mediafoundation/evrpresenter/Presenter.cpp

... the code that does the frame decode seems to be :

// ------------------------------------------------------------------------------------------------------------
dataBuffer.dwStreamID = 0;
dataBuffer.pSample = pSample;
dataBuffer.dwStatus = 0;
hr = m_pMixer->ProcessOutput(0, 1, &dataBuffer, &dwStatus);

// ------------------------------------------------------------------------------------------------------------

This performs a full frame decode. What should I do if (not_visible) to keep everything running smoothly please.

Have tried skipping the ProcessOutput but that buffers samples so need to be able to discard them somehow.

This : https://docs.microsoft.com/en-us/windows/desktop/api/mftransform/ns-mftransform-_mft_output_data_buffer

... says MFT_PROCESS_OUTPUT_DISCARD_WHEN_NO_BUFFER & set pSample above to null but that requires the output stream to have MFT_OUTPUT_STREAM_DISCARDABLE or MFT_OUTPUT_STREAM_LAZY_READ flag set, which I can read but not write.

So unclear how to skip unseen video frames (we're rendering in 3D, so sometimes you see it sometimes you don't but want audio to continue & everything to sync as it should).

Thanks in advance for any guidance. Have searched for sample code but have been unable to identify anything performing this function.

Can't pause as that breaks flow. Need audio to keep going as you can hear even when you can't see.

Find nearest key frame

$
0
0

Hello.

I am trying to implement a class, that would give the user the ability to save specified frames of a given video into a file. I already know how to do this and I am using IMFSourceReader for this purpose. However, I am interested only in key frames of the video. So I need the ability to find the nearest key frame to a specified position in video or at least, I need to be able to tell if given sample from a video corresponds to a key frame.

There is a service IMFSeekInfo, which would do the job it seems, but I am not sure how to obtain this service. The documentation says that to obtain this service, one has to call MFGetService with identifier MF_SCRUBBING_SERVICE, but it isn't even mentioned in the list of service interfaces in media foundation documentation and I don't know if it is even defined in some header (my guess is it should be defined in mfidl.h, but it is not).

I would very much appreciate any help with this. Thank you.

Viewing all 1079 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>