directshow播放mp4,显示不正常。 [英] directshow play mp4, display isn't normal.

查看:128
本文介绍了directshow播放mp4,显示不正常。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是使用directshow几天,我直接使用MPC-BE过滤器。

输入文件名后,点击播放按钮:

I'm just use directshow for some days, I directly use MPC-BE filters.
After input file name,then click play button:

void CAFPlayerDlg::OnBnClickedButtonPlay()
{
    HRESULT hr = NOERROR;
    CString fileName;
    m_edtFileName.GetWindowTextW(fileName);

    if(fileName.GetLength() <= 0)
        return;

    hr = m_pGraph->RenderFile(fileName.GetBuffer(), NULL);
    fileName.ReleaseBuffer();

    if(FAILED(hr))
        return;

    hr = m_pME->SetNotifyWindow((OAHWND)this->GetSafeHwnd(), WM_GRAPHNOTIFY, 0);
    SetDisplayWindow(m_stcVideoWindow.GetSafeHwnd());

    if(SUCCEEDED(hr)) {
        m_pMC->Run();
    }
}





SetDisplayWindow功能是:



SetDisplayWindow function is:

bool CAFPlayerDlg::SetDisplayWindow( HWND displayWindow )
{
    if(m_pVideoWindow) {
        m_pVideoWindow->put_Visible(OAFALSE);
        m_pVideoWindow->put_Owner((OAHWND)displayWindow);

        RECT rect;
        ::GetClientRect(displayWindow, &rect);
        m_pVideoWindow->put_Left(0);
        m_pVideoWindow->put_Top(0);
        m_pVideoWindow->put_Width(rect.right - rect.left);
        m_pVideoWindow->put_Height(rect.bottom - rect.top);
        m_pVideoWindow->put_WindowStyle(WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS); 

        m_pVideoWindow->put_MessageDrain((OAHWND)displayWindow);

        if(displayWindow) {
            m_pVideoWindow->put_Visible(OATRUE);
        } else {
            m_pVideoWindow->put_Visible(OAFALSE);
        }

        return true;
    }

    return false;
}





我添加了一些令人耳目一新的代码:



I has add some code for refreshing:

BOOL CAFPlayerDlg::OnInitDialog()
{
    CDialogEx::OnInitDialog();

    m_stcVideoWindow.ModifyStyle(0, WS_CLIPCHILDREN);

    CoInitialize(NULL);
    
    return TRUE;
}

BOOL CAFPlayerDlg::OnEraseBkgnd(CDC* pDC)
{
    CRect rc;
    // Get the bounding rectangle for the movie screen
    m_stcVideoWindow.GetWindowRect(&rc);
    ScreenToClient(&rc);
    // Exclude the clipping region occupied by our movie screen
   pDC->ExcludeClipRect(&rc);

    // Erase the remainder of the dialog as usual
    return CDialog::OnEraseBkgnd(pDC);
}

void CAFPlayerDlg::PreSubclassWindow()
{
    CDialog::PreSubclassWindow();
    this->ModifyStyle( 0, WS_CLIPCHILDREN | WS_CLIPSIBLINGS, 0 );
}





现在我可以播放mp4文件,我可以听到音乐声,但显示不正常。

请参阅图片:

[ https://drive.google.com/file/d/0BwyCt3NztyAPZFdkM2N3ZnoyczQ/edit?usp=sharing [< a href =https://drive.google.com/file/d/0BwyCt3NztyAPZFdkM2N3ZnoyczQ/edit?usp=sharing\"target =_ blanktitle =New Window> ^ ]]

推荐答案

您有视频解码器问题。

如果您使用defalt解码器,请尝试在过滤器图形中手动指定它,或者如果您已经使用过,请指定其他解码器您自己的解码器。



问候,

Maxim。
You have video decoder issue.
If you uses the defalt decoder, try to specify it manually in filter graph, or specify other one if you already uses your own decoder.

Regards,
Maxim.


这篇关于directshow播放mp4,显示不正常。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆