When changing a file name, Recording Start is overdue for 3 seconds.

℡╲_俬逩灬. 提交于 2019-12-31 06:53:06

问题


Using Two ASFWriter Filters in a graph.One is making wmv file, Anather is for live streaming.

Carrying out streaming, When changing a file name, Recording Start is overdue for 3 seconds. so,The head of a New WMV is missing. It's troubled.

CAMERA ------ InfTee Filter --- --- AsfWriter Filter → WMV FIle

                        X

Microphone --- InfTee Filter2 --- --- AsfWriter Filter2 → Live Streaming

void RecStart()
{
        ...

    ConnectFilters(pInfTee,"Infinite Pin Tee Filter(1)",L"Output1",pASFWriter,"ASFWriter",L"Video Input 01"));
    ConnectFilters(pInfTee,"Infinite Pin Tee Filter(2)",L"Output2",pASFWriter2,"ASFWriter",L"Video Input 01"));
    ConnectFilters(pSrcAudio,"Audio Source",L"Capture",pInfTee2,"Infinite Pin Tee Filter",L"Input"));
    ConnectFilters(pInfTee2,"Infinite Pin Tee Filter(1)A",L"Output1",pASFWriter,"ASFWriter",L"Audio Input 01"));
    ConnectFilters(pInfTee2,"Infinite Pin Tee Filter(2)A",L"Output2",pASFWriter2,"ASFWriter",L"Audio Input 01"));


    pASFWriter2->QueryInterface(IID_IConfigAsfWriter,(void**)&pConfig);

    pConfig->QueryInterface(IID_IServiceProvider,(void**)&pProvider);

    pProvider->QueryService(IID_IWMWriterAdvanced2, IID_IWMWriterAdvanced2, (void**)&mpWriter2);

    mpWriter2->SetLiveSource(TRUE);

    mpWriter2->RemoveSink(0);

    WMCreateWriterNetworkSink(&mpNetSink);

    DWORD dwPort = (DWORD)streamingPortNo;
    mpNetSink->Open(&dwPort);

    mpNetSink->GetHostURL(url, &url_len);

    hr =mpWriter2->AddSink(mpNetSink);


    pGraph->QueryInterface(IID_IMediaEventEx,(void **)&pMediaIvent);

    pMediaIvent->SetNotifyWindow((OAHWND)this->m_hWnd,WM_GRAPHNOTIFY,0);

    pGraph->QueryInterface(IID_IMediaControl,(void **)&pMediaControl);

    pMediaControl->Run();
}


void OnTimer()
{

    pMediaControl->Stop();

    CComQIPtr<IFileSinkFilter,&IID_IFileSinkFilter> pIFS = pASFWriter;
    pIFS->SetFileName(NewFilename,NULL);

    pMediaControl->Run();
}

---------------------------------------------------------------------------
→ I think ... In order to wait for starting of streaming, 
it is missing for 3 seconds in head of New WMV File.
Are there any measures? 
---------------------------------------------------------------------------

回答1:


When you restart the graph, you inevitably miss a fragment of data due to initialization overhead. And, it is impossible to switch files without stopping the graph. The solution is to use multiple graphs and keep capturing while the part with file writing is being reinitialized.

See DirectShow Bridges for a typical solution addressing this problem.



来源:https://stackoverflow.com/questions/11069603/when-changing-a-file-name-recording-start-is-overdue-for-3-seconds

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!