Control de video avi
Tengo que programar un activeX para poder editar un video avi y poder guardar un fragmento suyo. Es decir, a partir de un avi dado que dure 10 segundos, decir que me guarde el fragmento que va del 2 al 5 por ejemplo.
Tengo esta función de prueba, pero no consigo que me lo haga. Me crea el fichero de salida pero nada más. El fichero tiene 0 kb. No me graba nada.
Te mando el código de la función:
void CPlayerDlg::CrearFragmentoVideo()
{
ICaptureGraphBuilder2 *pBuild = NULL;
IGraphBuilder *pGraph = NULL;
IBaseFilter *pSrc = NULL; // Source filter
CoInitialize(NULL);
// Create the filter graph.
CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC,
IID_IGraphBuilder, (void **)&pGraph);
// Create the capture graph builder.
CoCreateInstance(CLSID_CaptureGraphBuilder2, NULL, CLSCTX_INPROC,
IID_ICaptureGraphBuilder2, (void **)&pBuild);
pBuild->SetFiltergraph(pGraph);
pGraph->AddSourceFilter(L"C:\\alberto\\clock.avi", L"Source Filter", &pSrc);
IBaseFilter *ppf = NULL;
IFileSinkFilter *pSink = NULL;
pBuild->SetOutputFileName(&MEDIASUBTYPE_Avi,
L"C:\\alberto\\output.avi",
&ppf,
&pSink);
REFERENCE_TIME rtStart = INICIO,
rtStop = 3*INICIO;
pBuild->ControlStream(
&PIN_CATEGORY_CAPTURE,
&MEDIATYPE_Video,
pSrc, // Source filter
&rtStart, // Start time
&rtStop, // Stop time
0, // Start cookie
0 // Stop cookie
);
// Render the video stream, through the compressor.
pBuild->RenderStream(
&PIN_CATEGORY_CAPTURE, // Pin category
&MEDIATYPE_Video, // Media type
pSrc, // Source filter
NULL, // Compressor filter
ppf); // Sink filter (the AVI Mux)
// Run the graph.
IMediaControl *pControl = NULL;
pGraph->QueryInterface(IID_IMediaControl, (void **)&pControl);
pControl->Run();
pSrc->Release();
ppf->Release();
pControl->Release();
pBuild->Release();
pGraph->Release();
pSink->Release();
CoUninitialize();
}
Muchas gracias
Tengo esta función de prueba, pero no consigo que me lo haga. Me crea el fichero de salida pero nada más. El fichero tiene 0 kb. No me graba nada.
Te mando el código de la función:
void CPlayerDlg::CrearFragmentoVideo()
{
ICaptureGraphBuilder2 *pBuild = NULL;
IGraphBuilder *pGraph = NULL;
IBaseFilter *pSrc = NULL; // Source filter
CoInitialize(NULL);
// Create the filter graph.
CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC,
IID_IGraphBuilder, (void **)&pGraph);
// Create the capture graph builder.
CoCreateInstance(CLSID_CaptureGraphBuilder2, NULL, CLSCTX_INPROC,
IID_ICaptureGraphBuilder2, (void **)&pBuild);
pBuild->SetFiltergraph(pGraph);
pGraph->AddSourceFilter(L"C:\\alberto\\clock.avi", L"Source Filter", &pSrc);
IBaseFilter *ppf = NULL;
IFileSinkFilter *pSink = NULL;
pBuild->SetOutputFileName(&MEDIASUBTYPE_Avi,
L"C:\\alberto\\output.avi",
&ppf,
&pSink);
REFERENCE_TIME rtStart = INICIO,
rtStop = 3*INICIO;
pBuild->ControlStream(
&PIN_CATEGORY_CAPTURE,
&MEDIATYPE_Video,
pSrc, // Source filter
&rtStart, // Start time
&rtStop, // Stop time
0, // Start cookie
0 // Stop cookie
);
// Render the video stream, through the compressor.
pBuild->RenderStream(
&PIN_CATEGORY_CAPTURE, // Pin category
&MEDIATYPE_Video, // Media type
pSrc, // Source filter
NULL, // Compressor filter
ppf); // Sink filter (the AVI Mux)
// Run the graph.
IMediaControl *pControl = NULL;
pGraph->QueryInterface(IID_IMediaControl, (void **)&pControl);
pControl->Run();
pSrc->Release();
ppf->Release();
pControl->Release();
pBuild->Release();
pGraph->Release();
pSink->Release();
CoUninitialize();
}
Muchas gracias
Respuesta de roly
-1