0

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 Answers1

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.

Roman R.
  • 68,205
  • 6
  • 94
  • 158
  • Thank you. I can allow the missing less than about 1 second. Isn't there any how to solve more easily? – Yoshiki Kubota Jun 17 '12 at 13:50
  • There is no easy solution. With a single graph, you do stop and then start. All initialization/finalization is the overhead and missing fragments. With multi-graph solution you can do it as smooth as missing no data at all. – Roman R. Jun 18 '12 at 10:20