locked
Trying to create simple example program with custom IMFByteStream RRS feed

  • Question

  • My goal is to create the simplest Media Foundation based program that can take video from my web cam transmit it across a network as H.264 and then display it on the remote end. From all my reading and experimenting to date I've judged that the most likely approach is to use a custom IMFByteStream (please correct me if I'm wrong although I've seen references to MFCreateASFStreamingMediaSink and haven't been able to get anywhere with it).

    At the moment I'm solely working on the first step which is to get a video feed from my web cam, transcode it to H.264 (my webcam supports RGB and YUV) and get samples into my custom IMFByteStream. I'm not yet at the stage where I'm attempting to do anything with the samples in my byte stream. The problem I'm having is that I can't seem to wire up my Media Foundation infrastructure correctly and I'm getting an error when I call BeginWrite on my sink writer. I'm pretty sure I've got the input and output source attributes set up correctly for the RGB to H.264 transcoding as it works if I use the sink writer provided by MFCreateSinkWriterFromURL but not if I use a sink writer provided by pClassFactory->CreateInstanceFromObject backed with my custom IMFByteStream object.

    My program is below. I've left out the IMFByteStream implementation as it's a completely empty shell except for GetCapabilities which does set the MFBYTESTREAM_IS_WRITABLE flag. I've also included the MTrace log obtained when running the program, the trace does end with MF_E_TRANSFORM_NEED_MORE_INPUT but I don't think that's the problem as that occurs on my program that is able to record H.264 video to a file and doesn't cause a problem.

    I'm sure I'm doing something wrong or missing something regarding the way I'm connecting up my sources and sinks and would be very grateful for any advice.

    int _tmain(int argc, _TCHAR* argv[])

    {
    printf("Custom IMFSinkWriter test console.\n");

    CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);

    // Initialize the Media Foundation platform.
    CHECK_HR(MFStartup(MF_VERSION), L"Error on Media Foundation startup.");

        HRESULT hr = WriteVideoToCustomByteStream();

    if(hr != S_OK)
    {
    printf("Write video returned an error.\n");
    }

    printf("press any key to exit...\n");
    getchar();

    return 0;
    }

    HRESULT WriteVideoToCustomByteStream()
    {
    IMFMediaSource *videoSource = NULL;
        UINT32 videoDeviceCount = 0;
        IMFAttributes *videoConfig = NULL;
        IMFActivate **videoDevices = NULL;
    IMFMediaType *videoType = NULL;
    IMFSourceReader *videoReader;
    DWORD videoStreamIndex = 0;
    IMFSinkWriter *pWriter = NULL;
    HRESULT hr = NULL;
    IMFReadWriteClassFactory *pClassFactory = NULL;
    CComPtr<IMFByteStream> myByteStream; 
    IMFMediaType *pVideoOutType = NULL;

    CHECK_HR(MyByteStream::CreateInstance(&myByteStream), L"Error creating my byte stream.");

        CHECK_HR(MFCreateAttributes(&videoConfig, 1), L"Error creating video source media type.");
    CHECK_HR(MFCreateMediaType(&pVideoOutType), L"Error creating video sink media type.");

    // Request video capture devices.
        CHECK_HR(videoConfig->SetGUID(
            MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE, 
            MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_GUID), L"Error initialising video configuration object.");

        // Enumerate the devices,
        CHECK_HR(MFEnumDeviceSources(videoConfig, &videoDevices, &videoDeviceCount), L"Error enumerating video devices.");
        CHECK_HR(videoDevices[0]->ActivateObject(IID_PPV_ARGS(&videoSource)), L"Error activating video device.");

    //CHECK_HR( hr = m_pAttributes->SetUINT32( MF_READWRITE_ENABLE_HARDWARE_TRANSFORMS,
        //                                         m_Options.fEnableHardwareTransforms ), L"" );

    // Create the source reader.
    CHECK_HR(MFCreateSourceReaderFromMediaSource(
    videoSource,
    videoConfig,
    &videoReader), L"Error creating video source reader.");

    CHECK_HR(videoReader->GetCurrentMediaType(
    (DWORD)MF_SOURCE_READER_FIRST_VIDEO_STREAM, 
    &videoType), L"Error retirieving current media type from first video stream.");
    //CMediaTypeTrace *videoTypeMediaTrace = new CMediaTypeTrace(videoType);
    //printf("Video input media type: %s.\n",  videoTypeMediaTrace->GetString());

    // Configure the output video type to be H.264.
    CHECK_HR(ConfigureEncoder(videoType, pVideoOutType), L"Error configuring encoder.");
    //printf("Video stream index %i.\n", videoStreamIndex);

        CHECK_HR( hr = CoCreateInstance( CLSID_MFReadWriteClassFactory,
                                         NULL,
                                         CLSCTX_INPROC_SERVER,
                                         IID_PPV_ARGS( &pClassFactory ) ), L"Error creating read write class factory." );

    CHECK_HR(hr = pClassFactory->CreateInstanceFromObject( CLSID_MFSinkWriter,
    myByteStream,
                                        pVideoOutType,
                                        IID_PPV_ARGS( &pWriter )), L"Error creating sink writer from custom byte stream." );

        CHECK_HR(pWriter->AddStream(pVideoOutType, &videoStreamIndex), L"Failed to add the video stream to the sink writer.");

    // Register the color converter DSP for this process, in the video 
    // processor category. This will enable the sink writer to enumerate
    // the color converter when the sink writer attempts to match the
    // media types.
    CHECK_HR(MFTRegisterLocalByCLSID(
    __uuidof(CColorConvertDMO),
    MFT_CATEGORY_VIDEO_PROCESSOR,
    L"",
    MFT_ENUM_FLAG_SYNCMFT,
    0,
    NULL,
    0,
    NULL
    ), L"Error registering colour converter DSP.");

    CHECK_HR(pWriter->SetInputMediaType(0, videoType, NULL), L"Error setting the sink writer video input type.");
    //videoType->Release();

    CHECK_HR(pWriter->BeginWriting(), L"Failed to begin writing on the sink writer.");

    DWORD streamIndex, flags;
    LONGLONG llVideoTimeStamp;
    IMFSample *videoSample = NULL;
    CRITICAL_SECTION critsec;
    BOOL bFirstVideoSample = TRUE;
    LONGLONG llVideoBaseTime = 0;
    int sampleCount = 0;

    InitializeCriticalSection(&critsec);

    printf("Recording...\n");

    while(sampleCount < 100)
    {
    // Initial read results in a null pSample??
    CHECK_HR(videoReader->ReadSample(
    MF_SOURCE_READER_ANY_STREAM,    // Stream index.
    0,                              // Flags.
    &streamIndex,                   // Receives the actual stream index. 
    &flags,                         // Receives status flags.
    &llVideoTimeStamp,                   // Receives the time stamp.
    &videoSample                        // Receives the sample or NULL.
    ), L"Error reading video sample.");

    wprintf(L"Video stream %d (%I64d)\n", streamIndex, llVideoTimeStamp);

    if (videoSample)
    {
    if (bFirstVideoSample)
    {
    llVideoBaseTime = llVideoTimeStamp;
    bFirstVideoSample = FALSE;
    }

    // rebase the time stamp
    llVideoTimeStamp -= llVideoBaseTime;

    CHECK_HR(videoSample->SetSampleTime(llVideoTimeStamp), L"Set video sample time failed.\n");
    CHECK_HR(pWriter->WriteSample(videoStreamIndex, videoSample), L"Write video sample failed.\n");
    }

    sampleCount++;
    }

    printf("Finalising the capture.");

    if (pWriter)
    {
    CHECK_HR(pWriter->Finalize(), L"Error finalising IMFCustomSinkWriter.");
    }

    // Shut down Media Foundation.
    MFShutdown();

        for (DWORD i = 0; i < videoDeviceCount; i++)
        {
            videoDevices[i]->Release();
        }
        CoTaskMemFree(videoDevices);

        return S_OK;
    }

    HRESULT ConfigureEncoder(IMFMediaType *pVideoType, /*[out]*/ IMFMediaType *pVideoOutType)
    {
        //IMFMediaType *pVideoOutType = NULL;

    // Configure the video stream.
    CHECK_HR(pVideoOutType->SetGUID(MF_TRANSCODE_CONTAINERTYPE, MFTranscodeContainerType_MPEG4), L"Failed to set the transcode container type on the sink writer.");
    //CHECK_HR(pVideoOutType->SetUINT32(MF_TRANSCODE_ADJUST_PROFILE, MF_TRANSCODE_ADJUST_PROFILE_DEFAULT), L"Failed to set the transcode adjust profile on the sink writer.");
        CHECK_HR(pVideoOutType->SetGUID( MF_MT_MAJOR_TYPE, MFMediaType_Video), L"Failed to set video writer attribute, media type.");     
        CHECK_HR(pVideoOutType->SetGUID(MF_MT_SUBTYPE, MFVideoFormat_H264), L"Failed to set video writer attribute, video format (H.264).");
        CHECK_HR(pVideoOutType->SetUINT32(MF_MT_AVG_BITRATE, 240 * 1000), L"Failed to set video writer attribute, bit rate.");
        CHECK_HR(CopyAttribute(pVideoType, pVideoOutType, MF_MT_FRAME_SIZE), L"Failed to set video writer attribute, frame size.");
        CHECK_HR(CopyAttribute(pVideoType, pVideoOutType, MF_MT_FRAME_RATE), L"Failed to set video writer attribute, frame rate.");
        CHECK_HR(CopyAttribute(pVideoType, pVideoOutType, MF_MT_PIXEL_ASPECT_RATIO), L"Failed to set video writer attribute, aspect ratio.");
        CHECK_HR(CopyAttribute(pVideoType, pVideoOutType, MF_MT_INTERLACE_MODE), L"Failed to set video writer attribute, interlace mode.");

        //pVideoOutType->Release();

        return S_OK;
    }

     __M_F_T_R_A_C_E___LOG__

    PID, TID    Time (UTC)    TraceMessage
    --------- --------------  ------------
    11172,32BC 23:51:58.12490 TraceOSVersion @ OS version (BuildLabEx): 7601.17790.amd64fre.win7sp1_gdr.120305-1505
    11172,32BC 23:51:58.12490 TraceMFDetoursVersion @ MFDetours version 1.0.0.1
    11172,32BC 23:51:58.12497 TraceEnabledKeywords @ Keywords and levels: Default 4, Detours 4, Kernel32Export 4, MFExport 4, MFPlatExport 4, MFPlayExport 4, MFReadWriteExport 4, Ole32Export 4, wmvCoreExport 4, MFPublic 4, IMFActivate 4, IMFAttributes 4, IMFClock 4, IMFMediaEventGenerator 4, IMFMediaSession 4, IMFMediaSink 4, IMFMediaSource 4, IMFMediaStream 4, IMFPMediaPlayer 4, IMFPMediaItem 4, IMFPMediaPlayerCallback 4, IMFPresentationClock 4
    11172,32BC 23:51:58.12506 TraceEnabledKeywords @ Keywords and levels: IMFQualityAdvise 4, IMFQualityAdvise2 4, IMFQualityManager 4, IMFSample 4, IMFSinkWriter 4, IMFSourceReader 4, IMFSourceReaderCallback 4, IMFSourceResolver 4, IMFStreamSink 4, IMFTopology 4, IMFTopologyNode 4, IMFTopoLoader 4, IMFTransform 4, IMediaObject 4, IMFSchemeHandler 4, IMFByteStream 4, IMFByteStreamHandler 4, IMFReadWriteClassFactory 4, IFilterGraph 4, IGraphBuilder 4
    11172,32BC 23:51:58.12507 TraceEnabledKeywords @ Keywords and levels: IMediaControl 4, IMemInputPin 4, IWMReader 4, IWMReaderCallback 4
    11172,32BC 23:51:58.12758 CMFMediaSessionDetours::Attach @0077AC08 Presentation clock @0077B860
    11172,32BC 23:51:58.13032 CMFPlatExportDetours::MFStartup @ Version=0x00020070, dwFlags=0x00000000
    11172,32BC 23:51:58.13103 CMFExportDetours::MFEnumDeviceSources @ MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE=MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_GUID
    11172,32BC 23:51:58.13104 CMFPlatExportDetours::MFTEnumEx @ Category: CLSID_VideoInputDeviceCategory, Flags: 0x00000004, input MT: <NULL>, output MT: <NULL>
    11172,32BC 23:51:58.13272 COle32ExportDetours::CoCreateInstance @ Created {62BE5D10-60EB-11D0-BD3B-00A0C911CE86} System Device Enumerator (C:\Windows\SysWOW64\devenum.dll) @00A183D8 - traced interfaces: 
    11172,32BC 23:51:58.13294 COle32ExportDetours::CoCreateInstance @ Created {860BB310-5D01-11D0-BD3B-00A0C911CE86} VFW Capture Class Manager (C:\Windows\SysWOW64\devenum.dll) @00A1BF88 - traced interfaces: 
    11172,32BC 23:51:58.13305 COle32ExportDetours::CoCreateInstance @ Created {62BE5D10-60EB-11D0-BD3B-00A0C911CE86} System Device Enumerator (C:\Windows\SysWOW64\devenum.dll) @00A18440 - traced interfaces: 
    11172,32BC 23:51:58.14370 CMFPlatExportDetours::MFTEnumEx @ Activate 00 @00793FE8, MF_TRANSFORM_CATEGORY_Attribute=CLSID_VideoInputDeviceCategory;MFT_TRANSFORM_CLSID_Attribute=MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_GUID;MF_TRANSFORM_FLAGS_Attribute=4;MFT_ENUM_HARDWARE_URL_Attribute=\\?\usb#vid_046d&pid_0990&mi_00#7&25955bc5&0&0000#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\{bbefb6c7-2fc4-4139-bb8b-a58bba724083};MFT_FRIENDLY_NAME_Attribute=Logitech QuickCam Pro 9000;MFT_OUTPUT_TYPES_Attributes=76 69 64 73 00 00 10 00 80 00 00 aa 00 38 9b 71 7d eb 36 e4 4f 52 ce 11 9f 53 00 20 af 0b a7 70 76 69 64 73 00 00 10 00 80 00 00 aa 00 38 9b 71 7d eb 36 e4 4f 52 ce 11 9f 53 00 20 af 0b a7 70 76 69 ...
    11172,32BC 23:51:58.14374 CMFExportDetours::MFEnumDeviceSources @ Source activate 00 @00794040, MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_CATEGORY=CLSID_VideoInputDeviceCategory;MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_HW_SOURCE=4;MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_SYMBOLIC_LINK=\\?\usb#vid_046d&pid_0990&mi_00#7&25955bc5&0&0000#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\{bbefb6c7-2fc4-4139-bb8b-a58bba724083};MF_DEVSOURCE_ATTRIBUTE_FRIENDLY_NAME=Logitech QuickCam Pro 9000;MF_DEVSOURCE_ATTRIBUTE_MEDIA_TYPE=76 69 64 73 00 00 10 00 80 00 00 aa 00 38 9b 71 7d eb 36 e4 4f 52 ce 11 9f 53 00 20 af 0b a7 70 ;MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE=MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_GUID
    11172,32BC 23:51:58.14409 COle32ExportDetours::CoCreateInstance @ New MFT @00791080, MF_TRANSFORM_ASYNC=1
    11172,32BC 23:51:58.14411 COle32ExportDetours::CoCreateInstance @ Created {8AC3587A-4AE7-42D8-99E0-0A6013EEF90F} Device Proxy MFT (C:\Windows\System32\mf.dll) @00791080 - traced interfaces: IMFTransform @00791080, 
    11172,32BC 23:51:58.14484 COle32ExportDetours::CoCreateInstance @ Created {720D4AC0-7533-11D0-A5D6-28DB04C10000} KsTopologyInfo Class (C:\Windows\SysWOW64\vidcap.ax) @00A18030 - traced interfaces: 
    11172,32BC 23:51:58.14684 COle32ExportDetours::CoCreateInstance @ Created {C6E13344-30AC-11D0-A18C-00A0C9118956} IAMDroppedFrames (C:\Windows\SysWOW64\kswdmcap.ax) @00A1C120 - traced interfaces: 
    11172,32BC 23:51:58.14713 COle32ExportDetours::CoCreateInstance @ Created {6A2E0670-28E4-11D0-A18C-00A0C9118956} IAMVideoControl (C:\Windows\SysWOW64\kswdmcap.ax) @00A1C170 - traced interfaces: 
    11172,32BC 23:51:58.14735 COle32ExportDetours::CoCreateInstance @ Created {C6E13370-30AC-11D0-A18C-00A0C9118956} IAMCameraControl (C:\Windows\SysWOW64\kswdmcap.ax) @00A1C190 - traced interfaces: 
    11172,32BC 23:51:58.14756 COle32ExportDetours::CoCreateInstance @ Created {C6E13360-30AC-11D0-A18C-00A0C9118956} IAMVideoProcAmp (C:\Windows\SysWOW64\kswdmcap.ax) @00A1C1B0 - traced interfaces: 
    11172,32BC 23:51:58.15571 CMFActivateDetours::ActivateObject @00794040 New MFT @00791080
    11172,32BC 23:51:58.15571 CMFActivateDetours::ActivateObject @00794040 New source @007B0DB0
    11172,32BC 23:51:58.15575 CMFMediaSourceDetours::TracePD @007B0DB0 Stream 0 (ID 0): selected 1, MT: MF_MT_MAJOR_TYPE=MEDIATYPE_Video;MF_MT_SUBTYPE=MFVideoFormat_RGB24;MF_MT_FRAME_SIZE=2748779069920 (640,480);MF_MT_DEFAULT_STRIDE=4294965376;MF_MT_ALL_SAMPLES_INDEPENDENT=1;MF_MT_FIXED_SIZE_SAMPLES=1;MF_MT_SAMPLE_SIZE=921600;MF_MT_AVG_BITRATE=221184000;MF_MT_FRAME_RATE=128849018881 (30,1);MF_MT_PIXEL_ASPECT_RATIO=4294967297 (1,1);MF_MT_INTERLACE_MODE=2;MF_MT_AM_FORMAT_TYPE=FORMAT_VideoInfo;MF_MT_FRAME_RATE_RANGE_MAX=128849018881 (30,1);MF_MT_FRAME_RATE_RANGE_MIN=21474836481 (5,1)
    11172,32BC 23:51:58.15578 CMFMediaSourceDetours::TracePD @007B0DB0 Stream 1 (ID 1): selected 0, MT: MF_MT_MAJOR_TYPE=MEDIATYPE_Video;MF_MT_SUBTYPE=MFVideoFormat_RGB24;MF_MT_FRAME_SIZE=1374389534960 (320,240);MF_MT_DEFAULT_STRIDE=4294966336;MF_MT_ALL_SAMPLES_INDEPENDENT=1;MF_MT_FIXED_SIZE_SAMPLES=1;MF_MT_SAMPLE_SIZE=230400;MF_MT_FRAME_RATE=4294967297 (1,1);MF_MT_PIXEL_ASPECT_RATIO=4294967297 (1,1);MF_MT_INTERLACE_MODE=2;MF_MT_AM_FORMAT_TYPE=FORMAT_VideoInfo;MF_MT_FRAME_RATE_RANGE_MAX=4294967297 (1,1);MF_MT_FRAME_RATE_RANGE_MIN=4294967297 (1,1)
    11172,32BC 23:51:58.15580 CMFReadWriteExportDetours::MFCreateSourceReaderFromMediaSource @ Source @007B0DB0, MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE=MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_GUID
    11172,32BC 23:51:58.15580 CMFReadWriteExportDetours::MFCreateSourceReaderFromByteStream @ Bytestream @007B0DB0, MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE=MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_GUID
    11172,32BC 23:51:58.15607 COle32ExportDetours::CoCreateInstance @ Created {48E2ED0F-98C2-4A37-BED5-166312DDD83F} MFReadWrite Class Factory (C:\Windows\System32\mfreadwrite.dll) @00772E0C - traced interfaces: IMFReadWriteClassFactory @00772E0C, 
    11172,32BC 23:51:58.15608 CMFReadWriteClassFactoryDetours::CreateInstanceFromObject @00772E0C Object @007B0DB0, MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE=MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_GUID
    11172,32BC 23:51:58.15611 CMFReadWriteClassFactoryDetours::HandleObject @ New source reader @0079A098
    11172,32BC 23:51:58.15627 COle32ExportDetours::CoCreateInstance @ Created {48E2ED0F-98C2-4A37-BED5-166312DDD83F} MFReadWrite Class Factory (C:\Windows\System32\mfreadwrite.dll) @00772E0C - traced interfaces: IMFReadWriteClassFactory @00772E0C, 
    11172,32BC 23:51:58.15629 CMFReadWriteClassFactoryDetours::CreateInstanceFromObject @00772E0C Object @02544DB0, MF_TRANSCODE_CONTAINERTYPE=MFTranscodeContainerType_MPEG4;MF_MT_MAJOR_TYPE=MEDIATYPE_Video;MF_MT_SUBTYPE=MEDIASUBTYPE_H264;MF_MT_AVG_BITRATE=240000;MF_MT_FRAME_SIZE=2748779069920 (640,480);MF_MT_FRAME_RATE=128849018881 (30,1);MF_MT_PIXEL_ASPECT_RATIO=4294967297 (1,1);MF_MT_INTERLACE_MODE=2
    11172,32BC 23:51:58.15630 CMFReadWriteClassFactoryDetours::HandleObject @ New sink writer @0079B0A0
    11172,32BC 23:51:58.15634 CMFSinkWriterDetours::AddStream @0079B0A0 Stream Index 0x0, MT: MF_TRANSCODE_CONTAINERTYPE=MFTranscodeContainerType_MPEG4;MF_MT_MAJOR_TYPE=MEDIATYPE_Video;MF_MT_SUBTYPE=MEDIASUBTYPE_H264;MF_MT_AVG_BITRATE=240000;MF_MT_FRAME_SIZE=2748779069920 (640,480);MF_MT_FRAME_RATE=128849018881 (30,1);MF_MT_PIXEL_ASPECT_RATIO=4294967297 (1,1);MF_MT_INTERLACE_MODE=2
    11172,32BC 23:51:58.15637 CMFPlatExportDetours::MFTEnumEx @ Category: MFT_CATEGORY_VIDEO_ENCODER, Flags: 0x00000073, input MT: <NULL>, output MT: MF_MT_MAJOR_TYPE=MEDIATYPE_Video;MF_MT_SUBTYPE=MEDIASUBTYPE_H264
    11172,32BC 23:51:58.15691 CMFPlatExportDetours::MFTEnumEx @ Activate 00 @007A8E28, MF_TRANSFORM_CATEGORY_Attribute=MFT_CATEGORY_VIDEO_ENCODER;MFT_TRANSFORM_CLSID_Attribute={6CA50344-051A-4DED-9779-A43305165E35};MFT_INPUT_TYPES_Attributes=76 69 64 73 00 00 10 00 80 00 00 aa 00 38 9b 71 49 59 55 56 00 00 10 00 80 00 00 aa 00 38 9b 71 76 69 64 73 00 00 10 00 80 00 00 aa 00 38 9b 71 59 56 31 32 00 00 10 00 80 00 00 aa 00 38 9b 71 76 69 ;MFT_OUTPUT_TYPES_Attributes=76 69 64 73 00 00 10 00 80 00 00 aa 00 38 9b 71 48 32 36 34 00 00 10 00 80 00 00 aa 00 38 9b 71 ;MFT_FRIENDLY_NAME_Attribute=H264 Encoder MFT;MF_TRANSFORM_FLAGS_Attribute=1
    11172,32BC 23:51:58.15741 COle32ExportDetours::CoCreateInstance @ New MFT @00A1C2D4, <NULL>
    11172,32BC 23:51:58.15742 COle32ExportDetours::CoCreateInstance @ Created {6CA50344-051A-4DED-9779-A43305165E35}  (C:\Windows\SysWOW64\mfh264enc.dll) @00A1C2D4 - traced interfaces: IMFTransform @00A1C2D4, 
    11172,32BC 23:51:58.15742 CMFActivateDetours::ActivateObject @007A8E28 New MFT @00A1C2D4
    11172,32BC 23:51:58.15743 CMFTransformDetours::SetInputType @00A1C2D4 Succeeded MT: <NULL>
    11172,32BC 23:51:58.15744 CMFTransformDetours::SetOutputType @00A1C2D4 Succeeded MT: <NULL>
    11172,32BC 23:51:58.15747 CMFTransformDetours::SetInputType @00A1C2D4 Failed MT: MF_MT_MAJOR_TYPE=MEDIATYPE_Video;MF_MT_SUBTYPE=MFVideoFormat_RGB24;MF_MT_FRAME_SIZE=2748779069920 (640,480);MF_MT_DEFAULT_STRIDE=4294965376;MF_MT_ALL_SAMPLES_INDEPENDENT=1;MF_MT_FIXED_SIZE_SAMPLES=1;MF_MT_SAMPLE_SIZE=921600;MF_MT_AVG_BITRATE=221184000;MF_MT_FRAME_RATE=128849018881 (30,1);MF_MT_PIXEL_ASPECT_RATIO=4294967297 (1,1);MF_MT_INTERLACE_MODE=2;MF_MT_AM_FORMAT_TYPE=FORMAT_VideoInfo;MF_MT_FRAME_RATE_RANGE_MAX=128849018881 (30,1);MF_MT_FRAME_RATE_RANGE_MIN=21474836481 (5,1)
    11172,32BC 23:51:58.16036 CMFTransformDetours::SetOutputType @00A1C2D4 Succeeded MT: MF_TRANSCODE_CONTAINERTYPE=MFTranscodeContainerType_MPEG4;MF_MT_MAJOR_TYPE=MEDIATYPE_Video;MF_MT_SUBTYPE=MEDIASUBTYPE_H264;MF_MT_AVG_BITRATE=240000;MF_MT_FRAME_SIZE=2748779069920 (640,480);MF_MT_FRAME_RATE=128849018881 (30,1);MF_MT_PIXEL_ASPECT_RATIO=4294967297 (1,1);MF_MT_INTERLACE_MODE=2;MF_MT_MPEG2_PROFILE=66;MF_MT_MPEG_SEQUENCE_HEADER=00 00 00 01 67 42 c0 1e 96 54 05 01 e9 80 80 40 00 00 00 01 68 ce 3c 80 
    11172,32BC 23:51:58.16041 CMFTransformDetours::SetInputType @00A1C2D4 Failed MT: MF_MT_MAJOR_TYPE=MEDIATYPE_Video;MF_MT_SUBTYPE=MFVideoFormat_RGB24;MF_MT_FRAME_SIZE=2748779069920 (640,480);MF_MT_DEFAULT_STRIDE=4294965376;MF_MT_ALL_SAMPLES_INDEPENDENT=1;MF_MT_FIXED_SIZE_SAMPLES=1;MF_MT_SAMPLE_SIZE=921600;MF_MT_AVG_BITRATE=221184000;MF_MT_FRAME_RATE=128849018881 (30,1);MF_MT_PIXEL_ASPECT_RATIO=4294967297 (1,1);MF_MT_INTERLACE_MODE=2;MF_MT_AM_FORMAT_TYPE=FORMAT_VideoInfo;MF_MT_FRAME_RATE_RANGE_MAX=128849018881 (30,1);MF_MT_FRAME_RATE_RANGE_MIN=21474836481 (5,1)
    11172,32BC 23:51:58.16041 CMFPlatExportDetours::MFTEnumEx @ Category: MFT_CATEGORY_VIDEO_PROCESSOR, Flags: 0x00000073, input MT: <NULL>, output MT: <NULL>
    11172,32BC 23:51:58.16057 CMFPlatExportDetours::MFTEnumEx @ Activate 00 @0079B960, MFT_TRANSFORM_CLSID_Attribute={98230571-0087-4204-B020-3282538E57D3};MF_TRANSFORM_CATEGORY_Attribute=MFT_CATEGORY_VIDEO_PROCESSOR;MF_TRANSFORM_FLAGS_Attribute=1;MFT_PROCESS_LOCAL_Attribute=1
    11172,32BC 23:51:58.16119 COle32ExportDetours::CoCreateInstance @ New MFT @007A8290, <NULL>
    11172,32BC 23:51:58.16121 COle32ExportDetours::CoCreateInstance @ Created {98230571-0087-4204-B020-3282538E57D3} Color Converter DMO (C:\Windows\SysWOW64\colorcnv.dll) @007A8290 - traced interfaces: IMFTransform @007A8290, IMediaObject @007A82A8, 
    11172,32BC 23:51:58.16122 CMFActivateDetours::ActivateObject @0079B960 New MFT @007A8290
    11172,32BC 23:51:58.16124 CMFTransformDetours::SetInputType @007A8290 Failed MT: <NULL>
    11172,32BC 23:51:58.16124 CMFTransformDetours::SetOutputType @007A8290 Failed MT: <NULL>
    11172,32BC 23:51:58.16129 CMFTransformDetours::SetInputType @007A8290 Succeeded MT: MF_MT_MAJOR_TYPE=MEDIATYPE_Video;MF_MT_SUBTYPE=MFVideoFormat_RGB24;MF_MT_FRAME_SIZE=2748779069920 (640,480);MF_MT_DEFAULT_STRIDE=4294965376;MF_MT_ALL_SAMPLES_INDEPENDENT=1;MF_MT_FIXED_SIZE_SAMPLES=1;MF_MT_SAMPLE_SIZE=921600;MF_MT_AVG_BITRATE=221184000;MF_MT_FRAME_RATE=128849018881 (30,1);MF_MT_PIXEL_ASPECT_RATIO=4294967297 (1,1);MF_MT_INTERLACE_MODE=2;MF_MT_AM_FORMAT_TYPE=FORMAT_VideoInfo;MF_MT_FRAME_RATE_RANGE_MAX=128849018881 (30,1);MF_MT_FRAME_RATE_RANGE_MIN=21474836481 (5,1)
    11172,32BC 23:51:58.16131 CMFTransformDetours::SetOutputType @007A8290 Succeeded MT: MF_MT_MAJOR_TYPE=MEDIATYPE_Video;MF_MT_SUBTYPE=MFVideoFormat_IYUV;MF_MT_FRAME_SIZE=2748779069920 (640,480);MF_MT_FRAME_RATE=128849018881 (30,1);MF_MT_PIXEL_ASPECT_RATIO=4294967297 (1,1);MF_MT_INTERLACE_MODE=2
    11172,32BC 23:51:58.16132 CMFTransformDetours::SetInputType @00A1C2D4 Succeeded MT: <NULL>
    11172,32BC 23:51:58.16132 CMFTransformDetours::SetOutputType @00A1C2D4 Succeeded MT: <NULL>
    11172,32BC 23:51:58.16134 CMFTransformDetours::SetInputType @00A1C2D4 Failed MT: MF_MT_MAJOR_TYPE=MEDIATYPE_Video;MF_MT_SUBTYPE=MFVideoFormat_IYUV;MF_MT_FRAME_SIZE=2748779069920 (640,480);MF_MT_FRAME_RATE=128849018881 (30,1);MF_MT_PIXEL_ASPECT_RATIO=4294967297 (1,1);MF_MT_INTERLACE_MODE=2
    11172,32BC 23:51:58.16536 CMFTransformDetours::SetOutputType @00A1C2D4 Succeeded MT: MF_TRANSCODE_CONTAINERTYPE=MFTranscodeContainerType_MPEG4;MF_MT_MAJOR_TYPE=MEDIATYPE_Video;MF_MT_SUBTYPE=MEDIASUBTYPE_H264;MF_MT_AVG_BITRATE=240000;MF_MT_FRAME_SIZE=2748779069920 (640,480);MF_MT_FRAME_RATE=128849018881 (30,1);MF_MT_PIXEL_ASPECT_RATIO=4294967297 (1,1);MF_MT_INTERLACE_MODE=2;MF_MT_MPEG2_PROFILE=66;MF_MT_MPEG_SEQUENCE_HEADER=00 00 00 01 67 42 c0 1e 96 54 05 01 e9 80 80 40 00 00 00 01 68 ce 3c 80 
    11172,32BC 23:51:58.16539 CMFTransformDetours::SetInputType @00A1C2D4 Succeeded MT: MF_MT_MAJOR_TYPE=MEDIATYPE_Video;MF_MT_SUBTYPE=MFVideoFormat_IYUV;MF_MT_FRAME_SIZE=2748779069920 (640,480);MF_MT_FRAME_RATE=128849018881 (30,1);MF_MT_PIXEL_ASPECT_RATIO=4294967297 (1,1);MF_MT_INTERLACE_MODE=2
    11172,29B4 23:51:58.16573 CMFTransformDetours::ProcessMessage @007A8290 Message type=0x10000000 MFT_MESSAGE_NOTIFY_BEGIN_STREAMING, param=00000000
    11172,29B4 23:51:58.16574 CMFTransformDetours::ProcessMessage @007A8290 Message type=0x10000003 MFT_MESSAGE_NOTIFY_START_OF_STREAM, param=00000000
    11172,29B4 23:51:58.16575 CMFTransformDetours::ProcessMessage @00A1C2D4 Message type=0x10000000 MFT_MESSAGE_NOTIFY_BEGIN_STREAMING, param=00000000
    11172,29B4 23:51:58.16575 CMFTransformDetours::ProcessMessage @00A1C2D4 Message type=0x10000003 MFT_MESSAGE_NOTIFY_START_OF_STREAM, param=00000000
    11172,29B4 23:51:58.16581 CMFTransformDetours::ProcessOutput @00A1C2D4 failed hr=0xC00D6D72 MF_E_TRANSFORM_NEED_MORE_INPUT
    11172,32BC 23:51:58.16582 CMFSinkWriterDetours::SetInputMediaType @0079B0A0 Stream Index 0x0, MT: MF_MT_MAJOR_TYPE=MEDIATYPE_Video;MF_MT_SUBTYPE=MFVideoFormat_RGB24;MF_MT_FRAME_SIZE=2748779069920 (640,480);MF_MT_DEFAULT_STRIDE=4294965376;MF_MT_ALL_SAMPLES_INDEPENDENT=1;MF_MT_FIXED_SIZE_SAMPLES=1;MF_MT_SAMPLE_SIZE=921600;MF_MT_AVG_BITRATE=221184000;MF_MT_FRAME_RATE=128849018881 (30,1);MF_MT_PIXEL_ASPECT_RATIO=4294967297 (1,1);MF_MT_INTERLACE_MODE=2;MF_MT_AM_FORMAT_TYPE=FORMAT_VideoInfo;MF_MT_FRAME_RATE_RANGE_MAX=128849018881 (30,1);MF_MT_FRAME_RATE_RANGE_MIN=21474836481 (5,1)
    11172,29B4 23:51:58.16586 CMediaObjectDetours::ProcessOutput @007A82A8 MediaBuffer @007909B8, flags 0x00000000, Time 0ms, Duration 0ms, Size 0B
    11172,29B4 23:51:58.16587 CMFTransformDetours::ProcessOutput @007A8290 failed hr=0xC00D6D72 MF_E_TRANSFORM_NEED_MORE_INPUT

    Thanks,

    Aaron

    Sunday, June 10, 2012 12:23 AM

All replies

  • Hi Aaron,

    I am trying to do exactly the same thing. Did you succeed with your code? Can you please provide me some sample code or any kind of direction?

    Thanks!

    Tuesday, July 31, 2012 6:12 PM
  • What is the error code that is being returned from BeginWriting?  That is important information for helping to diagnose the problem.  Unfortunately I do not have a camera that generates RGB24 video so I cannot replicate this scenario.
    Friday, August 17, 2012 6:31 PM