Jump to content
  • Advertisement
Sign in to follow this  
progman_rus

DirectShow doesnd play mp4 movie

This topic is 2647 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

basic code from this http://www.gamedev.n...irectshow-r1345

I try to play MP4 movie and failed
but AVI and FLV is OK

I catch E_FAIL this code: hr = m_pGraph->RenderFile( fileneme, NULL );

I have all codect and splitter in my system and play this file with Windows Media Player OK


bool Client::createAviInterface( HWND hWnd, const wchar_t* fileneme )
{
RECT rc;

CoInitialize(NULL);

HRESULT hr = CoCreateInstance( CLSID_FilterGraph, NULL, CLSCTX_INPROC, IID_IGraphBuilder, (void **)&m_pGraph );

// Create the filter graph manager.
if( S_OK != hr || !m_pGraph )
{
mGameModule->LogError( "CoCreateInstance CLSID_FilterGraph FAILED" );
return false;
}

hr = m_pGraph->QueryInterface( IID_IMediaControl, ( void** )&m_pMediaControl );
if( S_OK != hr || !m_pMediaControl )
{
mGameModule->LogError( "CoCreateInstance IID_IMediaControl FAILED" );
return false;
}

hr = m_pGraph->QueryInterface( IID_IVideoWindow, ( void** )&m_pVidWin );
if( S_OK != hr || !m_pVidWin )
{
mGameModule->LogError( "CoCreateInstance IID_IVideoWindow FAILED" );
return false;
}

// Build the graph.
hr = m_pGraph->RenderFile( fileneme, NULL );
if( S_OK != hr )
{
mGameModule->LogError( "Build the graph %S FAILED", fileneme );
return false;
}

mGameModule->LogInfo( "Build the graph OK.");

hr = m_pGraph->QueryInterface( IID_IMediaSeeking, (void**)&m_pMediaSeeking );
if( S_OK != hr || !m_pMediaSeeking)
{
mGameModule->LogError( "QueryInterface IID_IMediaSeeking FAILED" );

return false;
}

hr = m_pGraph->QueryInterface( IID_IMediaEventEx, (void**)&m_pMediaEvents );
if( S_OK != hr || !m_pMediaEvents)
{
mGameModule->LogError( "QueryInterface IID_IMediaEventEx FAILED" );

return false;
}

// Have the graph signal event via window callbacks for performance
m_pMediaEvents->SetNotifyWindow((OAHWND)hWnd, WM_GRAPHNOTIFY, 0);

LONGLONG lDuration = NULL;

m_pMediaSeeking->GetDuration( &lDuration );

hr = m_pGraph->QueryInterface( IID_IMediaPosition, ( void** )&m_pMediaPosition );
if( S_OK != hr || !m_pMediaPosition )
{
mGameModule->LogError( "QueryInterface IID_IMediaPosition FAILED" );
return false;
}

//Set the video window.
m_pVidWin->put_Owner( ( OAHWND )hWnd );
m_pVidWin->put_WindowStyle( WS_CHILD /*| WS_CLIPSIBLINGS*/ );
m_pVidWin->put_MessageDrain((OAHWND)hWnd);

::GetClientRect( hWnd, &rc );
m_pVidWin->SetWindowPosition( 0, 0, rc.right, rc.bottom );

// Run the graph.
m_pMediaControl->Run();

mGameModule->LogInfo( "OK" );

IPin *pPin = NULL;
IBasicAudio *audio = NULL;

hr = m_pGraph->QueryInterface(IID_IBasicAudio, reinterpret_cast<void **>(&audio));
if (!hr && audio)
{
float soundVolume = 1.0f;
soundVolume = 20 * log10( soundVolume );
hr = audio->put_Volume( static_cast<long>( 100 * soundVolume ) );

mGameModule->LogInfo("Set Volume: ");
}
else
{
mGameModule->LogError("QueryInterface IBasicAudio: ");
}

return true;
}

Share this post


Link to post
Share on other sites
Advertisement
In your code snippit you only test against S_OK.

There are many possible error results, E_FAIL is not listed among them.

Which one is your real error code?


The most common cause of playback failure is Codec Hell, where you have multiple players who all want to play the file, but the selected one actually can't. One of the simple ways to resolve it is to build your own list of potential players and try them one after another until one eventually succeeds.

Share this post


Link to post
Share on other sites

In your code snippit you only test against S_OK.

There are many possible error results, E_FAIL is not listed among them.

Which one is your real error code?


I have 0x80004005 it is E_FAIL name from erors table: http://msdn.microsoft.com/en-us/library/dd390090(VS.85).aspx

S_OK Success.
VFW_S_AUDIO_NOT_RENDERED Partial success; the audio was not rendered.
VFW_S_DUPLICATE_NAME Success; the Filter Graph Manager modified the filter name to avoid duplication.
VFW_S_PARTIAL_RENDER Some of the streams in this movie are in an unsupported format.
VFW_S_VIDEO_NOT_RENDERED Partial success; some of the streams in this movie are in an unsupported format.
E_ABORT Operation aborted.
E_FAIL Failure.
E_INVALIDARG Argument is invalid.
E_OUTOFMEMORY Insufficient memory.
E_POINTER NULL pointer argument.
VFW_E_CANNOT_CONNECT No combination of intermediate filters could be found to make the connection.
VFW_E_CANNOT_LOAD_SOURCE_FILTER The source filter for this file could not be loaded.
VFW_E_CANNOT_RENDER No combination of filters could be found to render the stream.
VFW_E_INVALID_FILE_FORMAT The file format is invalid.
VFW_E_NOT_FOUND An object or name was not found.
VFW_E_UNKNOWN_FILE_TYPE The media type of this file is not recognized.
VFW_E_UNSUPPORTED_STREAM Cannot play back the file: the format is not supported.
[/quote]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!