Re: What happened to the Multi-File parser?
- From: cfairles <cfairles@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 26 Mar 2008 09:44:04 -0700
"Daniel S" wrote:
On Mar 26, 6:47 am, cfairles <cfair...@xxxxxxxxxxxxxxxxxxxxxxxxx>
wrote:
This filter is exactly what I need. I have a set of 1-hour long mp4's that I
need to render and seek seamlessly in sequence, not in parallel. For example,
say there's 2 files and a slider bar tied to the duration of the combined
files. If dragged to the last half of the bar, the graph should automagically
switch source filters to the 2nd file.
The multi-file parser docs (http://msdn2.microsoft.com/en-us/library/ms787415(VS.85).aspx) say that all
you need to do is RenderFile or AddSourceFile for each one. But with a single
VMR(7) renderer, if I attempt to add the second file source I get
VFW_E_CANT_RENDER or whatever.
Something like:
LPTSTR part1 = "c:\part1.mp4";
LPTSTR part2 = "c:\part2.mp4"; //really these are in a std::vector...
CComPtr<IBaseFilter> m_pVmr;
CComPtr<IGraphBuilder> m_pGraph;
m_pGraph.CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER);
m_pVmr.CoCreateInstance(CLSID_VideoMixingRenderer, NULL,
CLSCTX_INPROC_SERVER);
m_pGraph->AddFilter(m_pVmr, NULL);
//set windowless, query windowless control, set clipping window etc etc
m_pGraph->RenderFile(part1, NULL);
m_pGraph->RenderFile(part2, NULL); //returns VFW_E_CANNOT_RENDER
I also tried using AddSourceFilters, collecting the source filters, loop
through their pins and either
RenderEx(pPin, AM_RENDEREX_RENDERTOEXISTINGRENDERERS, NULL) or
ConnectFilters(m_pGraph, pPin, m_pVmr);
both don't seem to work either.
I need to report things like the total duration, but IMediaSeeking's
GetDuration only returns the length of one video (if the code is even
compiling and stable).
A usual set is about 12 230mb 1-hour mp4s and this has to be done in a
production environment (i.e. clients won't tolerate waiting however long it
takes to join the things, let alone the 2-3 gig of space it requires...).
Can anyone point me in the right direction? Am I going to have to implement
my own parser filter? Am I not setting up the graph correctly?
Cheers,
Chris
You could perhaps check out DES (DirectShow Editing Services) or use
GmfBridge (http://www.gdcl.co.uk/articles/). Both frameworks can do
what you want.
However, both have their limitations and are not sufficient for all
scenarios.
DES, thanks for the tip. So far it looks like it should work but I got stuck
right off the bat trying to get two 30sec videos to run back to back. Heres
the code:
CComPtr<IAMTimeline> pTL;
CComPtr<IAMTimelineObj> pGroupObj;
CHECK_HR( pTL.CoCreateInstance(CLSID_AMTimeline, NULL, CLSCTX_INPROC_SERVER)
);
CHECK_HR( pTL->CreateEmptyNode(&pGroupObj, TIMELINE_MAJOR_TYPE_GROUP) );
CComQIPtr<IAMTimelineGroup> pGroup(pGroupObj);
AM_MEDIA_TYPE mtGroup;
ZeroMemory(&mtGroup, sizeof(AM_MEDIA_TYPE));
mtGroup.majortype = MEDIATYPE_Video;
CHECK_HR(pGroup->SetMediaType(&mtGroup));
CHECK_HR(pTL->AddGroup(pGroupObj));
// TRACK: Add a track to the group.
CComPtr<IAMTimelineObj> pTrackObj;
CComQIPtr<IAMTimelineComp> pComp(pGroup);
CHECK_HR(pTL->CreateEmptyNode(&pTrackObj, TIMELINE_MAJOR_TYPE_TRACK));
CHECK_HR(pComp->VTrackInsBefore(pTrackObj, 0));
CComQIPtr<IAMTimelineTrack> pTrack(pTrackObj);
LPTSTR f1 = TEXT("C:\\test1.mp4");
LPTSTR f2 = TEXT("C:\\test2.mp4");
//hardcoded these, I've tried using FixTimes etc, even used IMediaDet to get
the
//actual time (which is ~29.999 per file)
REFTIME start1=0.0, stop1=29.999;
REFTIME start2=30, stop2=60;
{
CComPtr<IAMTimelineObj> pSourceObj;
CHECK_HR(pTL->CreateEmptyNode(&pSourceObj, TIMELINE_MAJOR_TYPE_SOURCE));
CComQIPtr<IAMTimelineSrc> pSource(pSourceObj);
// Set the times and the file name.
CHECK_HR(pSourceObj->SetStartStop2(start1, stop1));
BSTR bstrFile = SysAllocString(f1);
CHECK_HR(pSource->SetMediaName(bstrFile));
SysFreeString(bstrFile);
CHECK_HR(pSource->SetMediaTimes2(start1, stop1));
CHECK_HR(pTrack->SrcAdd(pSourceObj));
}
{
CComPtr<IAMTimelineObj> pSourceObj;
CHECK_HR(pTL->CreateEmptyNode(&pSourceObj, TIMELINE_MAJOR_TYPE_SOURCE));
CComQIPtr<IAMTimelineSrc> pSource(pSourceObj);
// Set the times and the file name.
CHECK_HR(pSourceObj->SetStartStop2(start2, stop2));
CComBSTR bstrFile(f2);
CHECK_HR(pSource->SetMediaName(bstrFile));
CHECK_HR(pSource->SetMediaTimes(start1, stop1));
CHECK_HR(pTrack->SrcAdd(pSourceObj));
}
CComPtr<IRenderEngine> pRenderEngine;
CHECK_HR( pRenderEngine.CoCreateInstance(CLSID_RenderEngine, NULL,
CLSCTX_INPROC_SERVER) );
PreviewTL(pTL, pRenderEngine);
pRenderEngine->ScrapIt();
///PreviewTL ...
CComPtr<IGraphBuilder> pGraph;
// Build the graph.
CHECK_HR(pRender->SetTimelineObject(pTL));
CHECK_HR(pRender->ConnectFrontEnd( ));
CHECK_HR(pRender->RenderOutputPins( ));
// Run the graph.
CHECK_HR(pRender->GetFilterGraph(&pGraph));
CComQIPtr<IMediaControl> pControl(pGraph);
CComQIPtr<IMediaEvent> pEvent(pGraph);
pControl->Run();
long evCode;
pEvent->WaitForCompletion(INFINITE, &evCode);
pControl->Stop();
//// end code. ////
CHECK_HR just returns on error and all the code is executed so nothings
erroring out. I see the first video play to the end. For a brief second I see
the first frame of the second vid but the preview window exits very shortly
after.
Anything obvious? I'm not 100% certain about the MediaTime vs. SetStartStop.
From what I gather, SetStartStop specifies the position in the track andMediaTime is relative to the source. Since I want the whole files to play,
mediatime is just 0->End, setstartstop of first is 0->End, second is
littlebitafterEnd->2*End ... Is my interpretation of the MediaTime vs
SourceObj time correct?
Cheers,
Chris
.
- Follow-Ups:
- Re: What happened to the Multi-File parser?
- From: Joe Flynn
- Re: What happened to the Multi-File parser?
- References:
- What happened to the Multi-File parser?
- From: cfairles
- Re: What happened to the Multi-File parser?
- From: Daniel S
- What happened to the Multi-File parser?
- Prev by Date: Re: Custom Directshow source filter neccessary?
- Next by Date: Re: Custom Directshow source filter neccessary?
- Previous by thread: Re: What happened to the Multi-File parser?
- Next by thread: Re: What happened to the Multi-File parser?
- Index(es):
Relevant Pages
|