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

IMFSampleGrabberSinkCallback and MFVideoFormat_MP4V failing

$
0
0

Hello,

I have an application using IMFSampleGrabberSinkCallback to grab video frames. It works great for wmv, h.264 in .mp4 etc. But I found one file it just can't decode, and it's of type MFVideoFormat_MP4V (in mp4 container). The same multimedia file works in MF samples using the standard sink, e.g. "MFPlayer2". To make sure it wasn't just my code I downloaded this example which has the same problem: msdn.microsoft.com/en-us/library/windows/desktop/hh184779(v=vs.85).aspx

What happens is that the topology and session are successfully created, and no events I receive indicate any errors. I just don't get any callbacks to IMFSampleGrabberSinkCallback::OnProcessSample(). I even used MFTrace.exe to see if I could get any internal errors, but I don't see anything out of the ordinary. It's quite noisy however, so I could be missing something.

The only restriction on IMFSampleGrabberSinkCallback I can find from the docs is that it doesn't support protected content. But the PKEY_DRM_IsProtected field is 0, which means it's not protected right? The streams that work has the same value of this propery, so that shouldn't be it.

Does anyone know what's going on?

Below is the output of MFMediaPropDump on the file:

Container attributes:
        MF_PD_DURATION: 0h 1m 16.0s
        MF_PD_TOTAL_FILE_SIZE: 3834322
Media content has 1 stream(s)
    Stream #0 attributes:
        MF_SD_LANGUAGE: en
    Stream #0 has 1 media type(s)
    Media type #0:
        MF_MT_MAJOR_TYPE: MFMediaType_Video
        MF_MT_SUBTYPE: MFVideoFormat_MP4V
        MF_MT_FRAME_SIZE: 354x94
        MF_MT_USER_DATA:
            0x00, 0x00, 0x01, 0xB0, 0xF3, 0x00, 0x00, 0x01, 0xB5, 0x0E,
            0xE0, 0x40, 0xC0, 0xCF, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
            0x01, 0x20, 0x00, 0x84, 0x40, 0xFA, 0x28, 0x58, 0xA0, 0x5E,
            0xA3, 0x1F
        MF_MT_FRAME_RATE: 24.00000fps
        MF_MT_PIXEL_ASPECT_RATIO: 1:1
        MF_MT_INTERLACE_MODE: MFVideoInterlace_Progressive
        MF_MT_AM_FORMAT_TYPE: FORMAT_VideoInfo2
        MF_MT_SAMPLE_SIZE: 1
        MF_MT_MPEG4_SAMPLE_DESCRIPTION:
            0x00, 0x00, 0x00, 0xBF, 0x73, 0x74, 0x73, 0x64, 0x00, 0x00,
            0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xAF,
            0x6D, 0x70, 0x34, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
            0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x61, 0x70, 0x70, 0x6C,
            0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x01, 0x62,
            0x00, 0x5E, 0x00, 0x48, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00,
            0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0C, 0x4D, 0x50, 0x45,
            0x47, 0x2D, 0x34, 0x20, 0x56, 0x69, 0x64, 0x65, 0x6F, 0x00,
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18,
            0xFF, 0xFF, 0x00, 0x00, 0x00, 0x45, 0x65, 0x73, 0x64, 0x73,
            0x00, 0x00, 0x00, 0x00, 0x03, 0x37, 0x00, 0x00, 0x1F, 0x04,
            0x2F, 0x20, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
            0x00, 0x00, 0x00, 0x00, 0x05, 0x20, 0x00, 0x00, 0x01, 0xB0,
            0xF3, 0x00, 0x00, 0x01, 0xB5, 0x0E, 0xE0, 0x40, 0xC0, 0xCF,
            0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x20, 0x00, 0x84,
            0x40, 0xFA, 0x28, 0x58, 0xA0, 0x5E, 0xA3, 0x1F, 0x06, 0x01,
            0x02, 0x00, 0x00, 0x00, 0x10, 0x70, 0x61, 0x73, 0x70, 0x00,
            0x00, 0x01, 0x62, 0x00, 0x00, 0x01, 0x62, 0x00, 0x00, 0x00,
            0x00
        MF_MT_MPEG4_CURRENT_SAMPLE_ENTRY: 0
        MF_MT_AVG_BITRATE: 399734
Shell Metadata:
        PKEY_Media_Duration: 0h 1m 16.0s
        PKEY_Video_EncodingBitrate: 399728
        PKEY_Video_FrameWidth: 354
        PKEY_Video_FrameHeight: 94
        PKEY_Video_FrameRate: 24000
        PKEY_Video_Compression: MFVideoFormat_MP4V
        PKEY_Video_FourCC: MP4V
        PKEY_Video_HorizontalAspectRatio: 1
        PKEY_Video_VerticalAspectRatio: 1
        PKEY_Video_StreamNumber: 1
        PKEY_Video_TotalBitrate: 399728
        PKEY_DRM_IsProtected: 0


Improve render performance while scrubbing

$
0
0

Hi,

I my application I have the following scenario:

The play position is represented by a cursor. When it's moved with the mouse I want to represent the intermediate frames, not just move the cursor and at the end position, after the mouse button is un-clicked, and then display the frames. 

I'we done this by scrubbing (set playrate to 0), and start the video from the position that is relative to the cursor. Without using the complete event form the media session the renderer does not finish before the next draw mesage comes and noting will be displayed if the cursor is moved relatively fast. If you wait for each draw operation to finish then the cursor is way behind the mouse position.

I was thinking to use the IMFQualityAdvise interface to change the quality level. Will this improve the render performance? From my understanding and from observation I think the Media Foundation resamples the video resolution for each frame to match the window size or the monitor resolution, while in fullscreen. Another thing that is done is deinterlacing. Can these features be turned off?

Best Regards,

Alin 

Using the IMFQualityAdvise Interface in a video player

$
0
0

Hello,

In my application I try to change the Quality level in order test the performance improvement. Can you please tell me the steps that I need to do in order to get the IMFQualityAdvise::SetQualityLevel function. 

I read through all the info and help that is provided on the MSDN pages but nothing worked so far or there wasn't any example. 

I have tried the following:

Querying the Source:

  • hr = MFGetService(m_pSource,MF_QUALITY_SERVICES,IID_IMFQualityAdvise,(void**) &pQualityAdvise);
  • hr = -184329....

Querying the Session:

  • hr = MFGetService(m_pSession,MF_QUALITY_SERVICES,IID_PPV_ARGS(&pQualityAdvise));
  • hr = E_NOINTERFACE;

I also read that: 

  • The quality manager typically obtains this interface when the quality manager's IMFQualityManager::NotifyTopology method is called.
  • In a typical quality manager this method does the following:
  • Enumerates the nodes in the topology.

  • Calls IMFTopologyNode::GetObject to get the node's underlying object.

  • Queries for the IFMQualityAdvise interface.

How does this work?

Thank you,

Alin

Failing to play video after removing autoplay attribute

$
0
0

Hi,

I'm developing a media foundation plugin for a Windows Store Application and I have a problem right at the start before the video plays.

If I have the JavaScript tag: <video autoplay></video> everything works fine as expected.

If I remove the autoplay: <video></video> and run without a debugger attached, the player will say "The video failed to play." If I run with the debugger attached it will play the video.

My guess is that this has something to do with code executing more slowly with the debugger attached and some data is downloaded in the meanwhile when the player requests it while in the other case it doesn't have time to download data and displays an error.

Documentation is scarce so it's getting hard to understand what is going on under the cover.

Would really appreciate if someone could point me in the right direction on how to fix this issue.

Thank you,
Ricardo.

PS: I'm not really sure if this is the right place to ask this question as this is a Media Foundation plugin for a Windows Store app but couldn't find a better section under the windows store apps forums.


Ricardo Sabino --- http://www.ricardosabino.com

waveoutopen crashes on 64 bit system

$
0
0

Hello There,

I am using winmm library for audio output. but in windows 7 64 bit system my application is crashes on waveoutopen api. How to manage this api with 32 and 64bit?

Thanks and Regards.

MFPutWorkItem crashs app

$
0
0

Hi,

the following code is the "Begin" function from a component that i wrote to start a "Asynchronous Method" :

HRESULT LoopbackRecording::BeginRecording(IMFAsyncCallback *pCallback, IUnknown *pState)
{
	DWORD workQueue;

	IMFAsyncResult *pResult = NULL;

    	HRESULT hr = MFCreateAsyncResult(NULL, pCallback, pState, &pResult);
	if(SUCCEEDED(hr))MFAllocateWorkQueue(&workQueue);
    	if(SUCCEEDED(hr))
    	{
        	hr = MFPutWorkItem(workQueue, this, pResult);
		SAFE_RELEASE(pResult);
    	}
    	return hr;
}

The Problem is it gives a plain crash to desktop without any Information what happened. I read about the multithreaded work queue behavior in Windows 8 and that the default work queue there is dispatching the work items differently than in Windows 7. I did build my Asynchronous Method as described here, and the Callback like presented here. Any ideas ?

By the way, the "Calling Asynchronous Methods" code sample produces an "unresolved symbol _QISearch on CAsyncCallback::QueryInterface" error, even though the include of the shlwapi header and the classes are correct. The error comes from this line :

CMyCallback *pCB = new (std::nothrow) CMyCallback(pStream, &hr);

How can the classes and the includes of the headers are ok but when i call for constructing a CMyCallback in my app then it says unresolved smybol ?

I hope someone can help

regards

coOKie





How to use the WMV Screen encoder?

$
0
0

Hi,
I'm trying to use the wmv9 screen encoder with the sinkwriter but I get an error when setting the input type.

Here's what I'm doing (removed error checking for compactness):

videoFormat.bitRate = 16000000;
videoFormat.fps = 30;
videoFormat.height = 1080;
videoFormat.width = 1920;

HRESULT hr = MFCreateSinkWriterFromURL("video.wmv", NULL, NULL, &pWriter);

//output media type.
hr = MFCreateMediaType(&pMediaType);   
hr = pMediaType->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Video);     
hr = pMediaType->SetGUID(MF_MT_SUBTYPE, MFVideoFormat_MSS2);   
hr = pMediaType->SetUINT32(MF_MT_AVG_BITRATE, videoFormat.bitRate);   
hr = pMediaType->SetUINT32(MF_MT_INTERLACE_MODE, MFVideoInterlace_Progressive);   
hr = MFSetAttributeSize(pMediaType, MF_MT_FRAME_SIZE, videoFormat.width, videoFormat.height);   
hr = MFSetAttributeRatio(pMediaType, MF_MT_FRAME_RATE, videoFormat.fps, 1);   
hr = MFSetAttributeRatio(pMediaType, MF_MT_PIXEL_ASPECT_RATIO, 1, 1);   
hr = pWriter->AddStream(pMediaType, &videoStreamIndex);   
SafeRelease(&pMediaType);

 //input media type.
hr = MFCreateMediaType(&pMediaType);   
hr = pMediaType->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Video);   
hr = pMediaType->SetGUID(MF_MT_SUBTYPE, MFVideoFormat_RGB32);
hr = pMediaType->SetUINT32(MF_MT_INTERLACE_MODE, MFVideoInterlace_Progressive);   
hr = MFSetAttributeSize(pMediaType, MF_MT_FRAME_SIZE, videoFormat.width, videoFormat.height);
hr = MFSetAttributeRatio(pMediaType, MF_MT_FRAME_RATE, videoFormat.fps, 1);   
hr = MFSetAttributeRatio(pMediaType, MF_MT_PIXEL_ASPECT_RATIO, 1, 1);   

//Following line returns -1072868846, whatever that means
hr = pWriter->SetInputMediaType(videoStreamIndex, pMediaType, NULL);

Any suggestions?

Ordinary wmv encoders (wmv1-3) works fine btw.

a performace of IMFSinkWriter ??? (about encoding speed)

$
0
0

I developed an encoder using IMFSinkWriter(wmv + wma => wmv file). (http://msdn.microsoft.com/en-us/library/windows/desktop/ff819477(v=vs.85).aspx)

but I'm facing a problem. It is a performance of the encoder. My encoder processes 20 frames per 1 second . It is too slow

target resolution is 1280x720 and target bitrate is 3.5Mbps. And my computer's spec. are i5-2500 CPU(3.3Ghz) and 24GB memory. OS is Windows 7(64bits).

How can I improve my encoder's performance?


OPM Driver Certification was EXPIRED!!

$
0
0

Hello? I'm developing about OPM (Output Protection Manager).

I following sequence that was in "Using Output Protection" document.

First, I get a pointer that IDrect3DDevice9.

Second, call the OPMGetVideoOutputsFromIDirect3DDevice9Object function. And then, I get instances of IOPMVideoOutput.

Finally, call the StartInitialization function, and get certification. 

BUT, this certification's valid date was 2006-10-17 ~ 2007-10-12. that was expired!!!

However, It was applied MFPROTECTION_DISABLE <--- that was confirmed using the ITA.

I want know that even if the certificate has expired, the certificate is valid?

Or not upper, why applied MFPROTECTION_DISABLE?

And then, I want to get the corporation list that was certified PMP-OPM. It is possible?

PS, I using the GeForce GT 610, and Driver's version is 327.23

Known bugs in H.264 MFT encoder on Windows 8

$
0
0

1) Does not support documented GetBlob of MF_MT_MPEG_SEQUENCE_HEADER. From documentation :  "After the output type is set, the video encoder updates the type by adding the MF_MT_MPEG_SEQUENCE_HEADER attribute. This attribute contains the sequence header." This does not work on Windows 8 and one has to parse the first frame to pull out the SPS/PPS information which is needed to create a file format requiring this information separately (e.g. MP4, MKV). 

2) Rate control is not working as expected. If using Unconstrained VBR, the requested bitrate is completely ignored. If CBR is used, the achieved bitrate is about 20% higher than requested. 

I have posted these as questions in another thread, but without any replies, I must assume these are bugs that need to worked around in implementations using the MFT H.264 encoder on Windows 8. 

Please provide feedback if anyone knows what could be causing these problems.

Difficulty Definitively Configuring MediaFoundation's H264 Encoder Bit Rate

$
0
0

Hello All,

I am developing an MP4 (H264/AAC) export pipe using a SinkWriter object from MediaFoundation. I have the pipe fully implemented, and it is largely successfully operational. However, one thing sticks out as not behaving properly. When configuring the H264 encoder of the SinkWriter, via creating an output media type and adding this media type to the SinkWriter via AddStream(), the bit rate I set via MF_MT_AVG_BITRATE gets clipped at some seemingly arbitrary upper bound (at least as reported via pulling up 'Properties' in Windows Explorer on the exported .mp4 file, though from reported file size this reported bit rate seems to fit). This upper bound seems to vary for different samples of video media. However, for example, lets say I have VideoMediaA, which is 20 seconds of 1080p30 video of someone walking down a street. Also for the purpose of this example lets say when I export this video using my SinkWriter, the bit rate cap experienced on this video, when setting the bit rate directly via MF_MT_AVG_BITRATE, is 18Mbps, resulting in a file of about 45MB. No matter what value I set on the media type for MF_MT_AVG_BIT_RATE that is in excess of 18Mbps I cannot increase the bit rate of the exported file. The immediate visual results of this are that the image quality of this exported file is very low, with macro blocks abound in areas of subtle vignette. Note that I have tried setting different H264 levels, different H264 profiles, and different encoder control modes, and none seems to allow me to get past this apparent upper bound.

Seeking a way around this, I found that when 'properly' configuring the encoder to use a control mode of 'quality' (via: http://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/6da521e9-7bb3-4b79-a2b6-b31509224638/win7-h264-encoder-imfsinkwriter-cant-use-quality-vbr-encoding?forum=mediafoundationdevelopment), and when setting the quality to its maximum value, that being 100, and exporting my self-same example file, VideoMediaA, I am able to get a bit rate dramatically higher than that which is the apparent cap when setting the bit rate directly on the media type via MF_MT_AVG_BIT_RATE. When I say dramatically higher, I mean in the neighborhood of 70Mbps, as opposed to the aforementioned 18Mpbs. Adjusting this quality setting down from 100 allows me to export all over the bit rate spectrum underneath the bit rate that results from a quality of 100. When configuring the encoder via this 'quality' setting I am actually able to create an export that is of the quality I want - with one major caveat.

The export pipe I am creating is fitting into an existent application which has always, and will always by specification, give the user a control that allows the user to set the bit rate directly in terms of Mpbs (and not via an abstracted 'quality' setting). I cannot expose to the user this 'quality' setting, I must expose to the user a bit rate control. Thus I get to the question portion of this post:

1) Via MF_MT_AVG_BITRATE  on the output media type, is there a way to definitively set the bit rate in excess of this seemingly mysterious and undocumented upper bound? I mean, I know that bit rates in excess of this upper bound are possible via configuring the encoder for quality…

Failing that…

2) Is there some known mapping I can use that can map a desired bit rate to a quality setting? From my plotting of the results of exporting different frame-sized examples at different quality settings it seems to be some type of power curve, which is also dependent upon frame size, frame rate, and (unfortunately...) image contents.

Any help would be much appreciated!

Thanks in advance,
Josh

==================

Edit: I am performing my development and testing on a Win7 machine.






IMFSinkWriter: Merit validation failed for MFT (Intel Quick Sync Video H.264 Encoder MFT)

$
0
0

Hi,

We are actually trying the run a simple Reader --> Writer (transcoder, VC1 -> H264) in Media Foundation. 
The source data (VC1) is captured with our own equipment, so no "premium protected content" or similar is used, the goal is to use Intel® Quick Sync Video H.264 Encoder MFT.

Looking in the MediaFoundation trace log we can see that a hardware MFT is enumerated and created BUT it fails.

CoCreateInstance @ Created {4BE8D3C0-0515-4A37-AD55-E4BAE19AF471} Intel® Quick Sync Video H.264 Encoder MFT (c:\Program Files\Intel\Media SDK\mfx_mft_h264ve_w7_32.dll)
MFGetMFTMerit @ Merit validation failed for MFT @06A42CA0 (hr=E_FAIL)

We provide a IDirect3DDeviceManager9 pointer MediaFoundation when creating our source reader + sink writer according to the documentation.
It's rather strange that MF wants to use a protected media path. Are we supposed to pass some encoder params to disable this type of behavior? Any ideas?

Standard monitor with DVI cable is used with Windows 7

best regards,

Carl


Designing a MF application that runs under Vista and 7

$
0
0

Hello,

I am working on an application that has to run under Vista and 7. It uses MF to display video files. According to the MSDN Documentation about the Media Foundation Headers and Libraries, I have to load different libs if my target OS is Vista, compared to 7. 

If the target OS is Vista or Windows Server 2008 I need to load:  evr_vista.lib, mf_vista.lib, mfplat_vista.lib. Among others I am using MFCreateSourceResolver.

Can you please help shed some light with this topic.

  • How do I have to configure the Property Pages for my project?
  • Are the names for the DLLs the same under Vista and 7 that incorporate these LIBs?

Thank you for your help,

Alin


Remux H.264/AVC video stream MPEG-2 TS file format to MPEG-4 file format

$
0
0

with reference to H.264/AVC Remux MFT.I have tried to remux MPEG2TS (AVC stream) to write MP4 File format.

    HRESULT hr;
    void* buf; 
    DWORD pcbWritten=NULL;
    CLSID guid;
    IMFMediaType* pMediaType;
    IMFStreamSink* pStream;
    IMFTransform* pIMFTransform=NULL;
    IMFMediaSink* m_pMediaSink;

    LPWSTR guidstr =L"{05A47EBB-8BF0-4CBF-AD2F-3B71D75866F5}";  
    LPCWSTR m_pszOutputFile=L"D:\\test.mp4";
    hr = CLSIDFromString(guidstr, (LPCLSID)&guid);

    if (FAILED(hr))
    {
        OutputDebugString(_T("ERROR IN CLSID\n"));
    }
    hr = CoCreateInstance(
        guid ,
        NULL,
        CLSCTX_INPROC_SERVER,
        IID_IMFTransform,
        (void**) &pIMFTransform
        );
    if (FAILED(hr)) {
        OutputDebugString(_T("FAILED IN CreateInstance\n"));
    }


    IMFByteStream* stream = NULL;
    hr= MFCreateFile(
        MF_ACCESSMODE_READ,
        MF_OPENMODE_DELETE_IF_EXIST,
        MF_FILEFLAGS_NONE,
        m_pszOutputFile,
        &stream);

    if(FAILED(hr))
    {
        OutputDebugString(L"ERROR>> Failed to create output file for MP4 Sink ");
    }

I'm getting a MPEG2TS packet but can't able to recode to MP4 File.

I've came across the following samples.

H.264 Video Decoder

Tutorial: Encoding an MP4 File

Tutorial: Using the Sink Writer to Encode Video

But i didn't get clear view to implement it further.

Please suggest some link to Decode MPEG2TS (AVC Stream) packet to MP4 File.


Arun kumar non ascii

How to debug a grayscale MFT in my project

$
0
0

Hi all,

I used the " MF_basicPlayback" example, and I add the MFT_Grayscale example to MF_basicPlayback project.

If I want to set a break point in MFT_Grayscale and debug it, how to do this?

Just like the mediaCapture sample in Windows store app example.

How to link the MFT_Grayscale to MF_basicPlayback?

Thanks.


IMFSinkWriter::BeginWriting() returns E_INVALIDARG when using custom IMFByteStream

$
0
0

Hello,

I'm writing a helper class for the game engine to capture RGB32 video framebuffer and convert it into H264 network stream. I decided to use Sink Writer with custom byte stream implementation. So basically my Library works like this:

1. Game engine sends frame buffer to my library

2. My class encodes raw RGB32 bytes into H264 samples

3. My class pushes back encoded video back to game engine

4. Game Engine sends compressed video over the network

This should be fairly easy to accomplish, but when I call IMFSinkWriter::BeginWriting(), it  returnsE_INVALIDARG

My IMFByteStream implementation is trivial and contains only  IMFByteStream::GetCapabilities() method that returnsMFBYTESTREAM_IS_WRITABLE

Below I listed all steps that my class makes:

  • Call CoInitializeEx() and MFStartup()
  • Create Writer Attributes with MF_TRANSCODE_CONTAINERTYPE
  • Instantiate my custom Byte Stream 
  • Call MFCreateSinkWriterFromURL(NULL, pBS, m_pWriterAttributes, &m_pWriter) 
  • Create Input and Output Media types
  • call m_pWriter->AddStream(m_pOutputMediaType, &streamIndex) and m_pWriter->SetInputMediaType(streamIndex, m_pInputMediaType, NULL) 
  • call m_pWriter->BeginWriting() 

At this point I get that error and I'm not sure what could be causing it. 

When I  call MFCreateSinkWriterFromURL("output.mp4", NULL, NULL,  &m_pWriter) everything works just fine. The file is created and I'm able to succesfully play it. This makes me think, that my Sink Writer was setup correctly and the problem is with this custom Byte Stream.  The only implemented method for ByteStream isGetCapabilities() which returns MFBYTESTREAM_IS_WRITABLE .

The Only clue is that Once m_pWriter->BeginWriting() is called,  MF API callsIMFByteStream::QueryInterface() once. It requests - IID_IMFMediaSink which cannot be handled and  E_NOINTERFACE is returned.

Below I'm posting some code snippets which I believe could be relevant to this problem. 

//SinkByteStream implements IMFByteStream
HRESULT SinkByteStream::QueryInterface(REFIID riid, void** ppv) 
{
	HRESULT hr = S_OK;
	static const QITAB qit[] =
	{
		QITABENT(SinkByteStream, IMFAsyncCallback),
		QITABENT(SinkByteStream, IMFByteStream),
		{ 0 },
	};
	hr = QISearch(this, qit, riid, ppv);
	return hr;
}

HRESULT SinkByteStream::GetCapabilities( DWORD *pdwCapabilities )
{
	HRESULT hr = S_OK;
	*pdwCapabilities = MFBYTESTREAM_IS_WRITABLE ;
	return hr;
}
//***************************************************
//LibStreaming2 is the actuall class that does all the 
work
//***************************************************

//Create the Sink Writer
HRESULT LibStreaming2::CreateSinkWriter()
{
	HRESULT hr = S_OK;
	IMFByteStream* pBS = NULL;
	
	do 
	{
		CHECK_HR(hr = CreateWriterAttributes());
		CHECK_HR(hr = SinkByteStream::CreateInstance(NULL,&pBS));
		CHECK_HR(hr = MFCreateSinkWriterFromURL(NULL, pBS, m_pWriterAttributes, &m_pWriter));
		CHECK_HR(hr = ConfigureSinkWriter());
	} while (false);

	if (FAILED(hr))
	{
		LOG("Failed to create Sink Writer");
	}
	SafeRelease(&pBS);
	return hr;
}

//Configure the Sink Writer
HRESULT LibStreaming2::ConfigureSinkWriter()
{
	HRESULT hr = S_OK;
	DWORD streamIndex;
	assert(m_pWriter);
	do 
	{
		CHECK_HR(hr = CreateOutputMediaType());
		CHECK_HR(hr = CreateInputMediaType());
		CHECK_HR(hr = m_pWriter->AddStream(m_pOutputMediaType, &streamIndex));
		CHECK_HR(hr = m_pWriter->SetInputMediaType(streamIndex, m_pInputMediaType, NULL));
		m_bWriterReady = true;
	} while (false);
	return hr;
}

//Configure input Media Type
HRESULT LibStreaming2::CreateInputMediaType()
{
	HRESULT  hr = S_OK;
	// Set the input media type.
	assert(m_pStreamParams);
	do 
	{
		CHECK_HR(hr = MFCreateMediaType(&m_pInputMediaType));   
		CHECK_HR(hr =  m_pInputMediaType->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Video));   
		CHECK_HR(hr =  m_pInputMediaType->SetGUID(MF_MT_SUBTYPE, MFVideoFormat_RGB32))
		CHECK_HR(hr =  m_pInputMediaType->SetUINT32(MF_MT_INTERLACE_MODE, MFVideoInterlace_Progressive))
		CHECK_HR(hr =  MFSetAttributeSize(m_pInputMediaType, MF_MT_FRAME_SIZE, m_pStreamParams->StreamWidth, m_pStreamParams->StreamHeight))
		CHECK_HR(hr =  MFSetAttributeRatio(m_pInputMediaType, MF_MT_FRAME_RATE, m_pStreamParams->StreamFramerate, 1))
		CHECK_HR(hr =  MFSetAttributeRatio(m_pInputMediaType, MF_MT_PIXEL_ASPECT_RATIO, 1, 1));   
	} while (false);
	if(FAILED(hr))
	{
		LOG("Failed to create input media type");
	}
	return hr;
}

//Create output Media Type
HRESULT LibStreaming2::CreateOutputMediaType()
{
	HRESULT hr = S_OK;
	assert(m_pStreamParams);
	do 
	{
		CHECK_HR(hr = MFCreateMediaType(&m_pOutputMediaType));
		CHECK_HR(hr = m_pOutputMediaType->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Video));
		CHECK_HR(hr = m_pOutputMediaType->SetGUID(MF_MT_SUBTYPE, MFVideoFormat_H264));
		CHECK_HR(hr = m_pOutputMediaType->SetUINT32(MF_MT_AVG_BITRATE, 800000));
		CHECK_HR(hr = MFSetAttributeRatio(m_pOutputMediaType, MF_MT_FRAME_RATE, m_pStreamParams->StreamFramerate, 1));
		CHECK_HR(hr = MFSetAttributeSize(m_pOutputMediaType, MF_MT_FRAME_SIZE, m_pStreamParams->StreamWidth, m_pStreamParams->StreamHeight));
		CHECK_HR(hr = m_pOutputMediaType->SetUINT32(MF_MT_INTERLACE_MODE, MFVideoInterlace_Progressive));
	} while (false);
	if(FAILED(hr))
	{
		LOG("Failed to create output media type");
	}
	return hr;
}

//Create Sink Writer Attributes
HRESULT LibStreaming2::CreateWriterAttributes()
{
	HRESULT hr = S_OK;
	do 
	{
	CHECK_HR(hr = MFCreateAttributes(&m_pWriterAttributes, 0));
	CHECK_HR(hr = m_pWriterAttributes->SetGUID(MF_TRANSCODE_CONTAINERTYPE, MFTranscodeContainerType_MPEG4));
	} while (false);
	if(FAILED(hr))
	{
	LOG("Failed to create Writer Configuration Attributes");
	}
	return hr;
}

Any help will be greatly appreciated :)

Best Regards,

Pawel M.


Win7 + H.264 Encoder + IMFSinkWriter Can't use Quality VBR encoding?

$
0
0

I'm trying to alter the encoder quality property eAVEncCommonRateControlMode_Quality via ICodecAPI.

However the setting is ignored as started in the documentation which says the property must be set before IMFTransform::SetOutputType is called.

Now here is the problem: the sink writer seems to call IMFTransform::SetOutputType when we call SetInputMediaType on the sink writer, however if we don't call SetInputMediaType we can't retrieve the ICodecAPI interface via sinkWriter.GetServiceForStream (throws exception) to change the quality setting..seems like a catch 22. I'm hoping it's me and not just a design flaw in the APIs.

Setting the quality property works on Win8, as Win8 does not ignore if when called after IMFTransform::SetOutputType is called.

Help!!

 

IMFVideoRenderer InitializeRenderer function takes 250+ ms

$
0
0

I have a custom evr presenter.

And it takes 250+ ms to set it to evr with InitializeRenderer. Even setting null mixer and null presenter, it still takes 250+ ms.

>_<

Here is my code.

CComPtr<IMFVideoRenderer> mf_renderer;
HRESULT hr = _render_filter->QueryInterface(
    IID_IMFVideoRenderer,
    reinterpret_cast<void**>(&mf_renderer));
if(FAILED(hr)) {
    return hr;
}

hr = mf_renderer->InitializeRenderer(nullptr, video_presenter);

Is that normal?

- Showery.


The H.264/AVC Remux MFT mystery

$
0
0

Hi,

I am trying to follow the guide "When and How to Use H.264/AVC Remux MFT and MP4 Sink" (http://msdn.microsoft.com/en-us/library/windows/desktop/jj553440(v=vs.85).aspx)

First I tried to create a instance of the MFT (IMFTransform) but the return value I got was "no class in registry".

Then I tried to let the topology resolver handle stuff for me according to:

"Set the source output media type to MFVideoFormat_H264_ES, which indicates each sample might not contain a complete primary picture. Set the input media type of MP4 sink to MFVideoFormat_H264. So, the input media type of the H.264/AVC remux MFT is MFVideoFormat_H264_ES and the output media type of the H.264/AVC remux MFT is MFVideoFormat_H264, which will be automatically inserted into the topology resolver"

This also did not work.

What am I missing here? The documentation is not the best...

Best Regards,

Carl


Async Transform with Multiple Output Streams

$
0
0

Hi guys,

I'm trying to implement an async transform with more than one input and output streams (video only). Currently the input part works, and it also works with only one output.

When I try to switch to 2 outputs, the first stream is showing in the sink perfectly (the sink is EVR taken from TopoEdit), but the second renderer window is solid black. 

Also when I try to switch to 3 outputs, the first stream is stuck on the first frame, and the two other windows are all solid black. ProcessOutput is called only once, even though my ProcessInput gets called twice for every input stream and I have sent METransformHaveOutput events twice. 

This is the output media type. It is used for all output streams regardless of the number of output pins.

    MF_MT_MAJOR_TYPE = MFMediaType_Video
    MF_MT_SUBTYPE = MFVideoFormat_YV12
    MF_MT_FIXED_SIZE_SAMPLES = 1
    MF_MT_ALL_SAMPLES_INDEPENDENT = 1
    MF_MT_FRAME_SIZE = N: 320  D: 240
    MF_MT_FRAME_RATE = N: 1  D: 30
    MF_MT_INTERLACE_MODE = 2
    MF_MT_PIXEL_ASPECT_RATIO = N: 1  D: 1
    MF_MT_SAMPLE_SIZE = 115200
    MF_MT_DEFAULT_STRIDE = 320

The ProcessOutput call works fine - all output buffers contains valid data before exiting the method call.

Every output pin of the transform is attached to an EVR window directly.

Stuck on this for a week now - any help would be much appreciated.

If anyone has a working example of multiple-output async transform that would help as well.
Viewing all 1079 articles
Browse latest View live


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