0

This is from a 2009 Microsoft project, and I'm not sure why I'm getting an error specifically in Windows-8. Here is the link: MSDN MFCopy

This happens when using the '-v' option 'Set Video Format', I get this error: "Failed to negotiate a format between the source reader and sink writer".

Keep in mind, I am processing the same video files in Win-7 and 8.

Edit: Is this a WinAPI issue? Is there some differences in the calls that need to be made? if so, can that be repaired in the source...

Example Usage is:

MfCopy.exe -t -xa -v WVC1 -r 270 "g:\pd1.mov" "g:\pd3.wmv"

'-t' = Trim Black frames
'-xa' = Video only
'-r' (270) = Rotate 270 degrees
'-v' (WVC1) = (Video options, H264, WMV2, WMV3, WVC1... none work in Win-8)  

I also have the sourcecode, and I can debug. Again it runs fine in Win-7. But in Win-8, I get an error specifically at this line:

  hr = m_pSinkWriter->SetInputMediaType( streamInfo.dwOutputStreamIndex,
                                           pFullMediaType,
                                           NULL );

The error is: 'The data specified for the media type is invalid, inconsistent, or not supported by this object'.

That is in this code block:

/////////////////////////////////////////////////////////////////
HRESULT CMFCopy::_NegotiateStreamFormat(
   __in DWORD dwStreamIndex,
   __in REFGUID guidMajorType,
   __in DWORD cFormats,
   __in_ecount( cFormats ) const GUID **paFormats )
{
HRESULT hr = S_OK;

const StreamInfo& streamInfo = m_paStreamInfo[dwStreamIndex];

IMFMediaType *pPartialMediaType = NULL;
IMFMediaType *pFullMediaType = NULL;

BOOL fConfigured = FALSE;

CHECK_HR( hr = MFCreateMediaType( &pPartialMediaType ) );

CHECK_HR( hr = pPartialMediaType->SetGUID( MF_MT_MAJOR_TYPE, guidMajorType )    );

for( DWORD ii = 0; ii < cFormats; ii++ )
{
    SAFE_RELEASE( pFullMediaType );

    CHECK_HR( hr = pPartialMediaType->SetGUID( MF_MT_SUBTYPE, *paFormats[ii] ) );

    // try to set the partial media type on the source reader
    hr = m_pSourceReader->SetCurrentMediaType( dwStreamIndex,
                                               NULL,
                                               pPartialMediaType );
    if( S_OK != hr )
    {
        // format is not supported by the source reader, try the next on the list
        hr = S_OK;
        continue;
    }

    // get the full media type from the source reader
    CHECK_HR( hr = m_pSourceReader->GetCurrentMediaType( dwStreamIndex,
                                                         &pFullMediaType ) );

    if (MFMediaType_Video == guidMajorType)             
    {
        _UpdateInputVideoStreamOverscanLineCount(pFullMediaType);
        if (RotateNone != m_Options.eRotation)
        {
            CHECK_HR( hr = GetDefaultStride(pFullMediaType, &m_srcDefaultStride)); // get the default stride for the source
            CComPtr<IMFMediaType> spRotatedMediaType;
            CHECK_HR(hr = hr = CreateRotatedMediaType(pFullMediaType, spRotatedMediaType, _simpleOverScanLines));
            pFullMediaType->Release(); 
            pFullMediaType = spRotatedMediaType.Detach(); // transfer ownership
        }
    }

    // try to set the input media type on the sink writer
    hr = m_pSinkWriter->SetInputMediaType( streamInfo.dwOutputStreamIndex,
                                           pFullMediaType,
                                           NULL );
    if( S_OK != hr )
    {
        // format is not supported by the sink writer, try the next on the list
        hr = S_OK;
        continue;
    }

    if (MFMediaType_Video == guidMajorType)
    {           
        CHECK_HR( hr = _UpdateRotationInfo(pFullMediaType)); // may need to update info about rotated image

    }


    fConfigured = TRUE;

    break;
}

if( !fConfigured )
{
    hr = MF_E_INVALIDMEDIATYPE;
    _SetErrorDetails( hr, L"Failed to negotiate a format between the source reader and sink writer" );
    goto done;
}

done:

SAFE_RELEASE( pPartialMediaType );
SAFE_RELEASE( pFullMediaType );

return( hr );

}

Robert Koernke
  • 436
  • 3
  • 18
  • Do you have the same filters installed on both machines? – IInspectable Aug 18 '15 at 22:08
  • Pardon my ignorance, but I'm assuming you mean some sort-of video filters. Perhaps you mean a 'filter' for the MOV format that a Canon camera produces? maybe. That's where the original video is coming from. Again ignorance. MFcopy.exe for us is part of a larger install that goes out to our clients. We discovered that the 'motion' building piece is failing for Win-8. Is there some extra "filters" that are preinstalled on Win-7 machines that I don't know about? Or that are failing to install... The answer to your question is 'I'm not sure'... where would I look? – Robert Koernke Aug 19 '15 at 12:31
  • I installed 'Nirsofts Installed' codec app, and I looked at all of them. I still am not sure what I'm looking for on both machines. One thing of note: It's not that the Win-8 machine cannot play the .MOV files in Windows-Media-Player, they play fine. I recorded a new one with the camera, and it even comes with sound. – Robert Koernke Aug 19 '15 at 13:20
  • I switched to ffmpeg, and abandoned MFCopy. It was tuff to adapt all the settings. ffmpeg seemed to not have a direct transcode to WVC1 or Windows Advanced Media Codec 9, also called wmv3. But I worked around the issue. This gets close to the same output: `code`ffmpeg.exe -y -i pd1.mov -vf "transpose=3, blackframe" -an -vcodec wmv2 -q 1 -trellis 2 "g:\pd2.wmv" – Robert Koernke Aug 25 '15 at 19:27

0 Answers0