The following code demonstrates how to create DVD images using LEAD Multimedia toolkit.
#include "ltmm.h"#include "ILTDvdWriter2.h"#include <TChar.h>LPOLESTR T2OLE(LPCTSTR lpt){static OLECHAR lpw[512];if(!lpt)return NULL;lpw[0] = L'\0';MultiByteToWideChar(CP_ACP, 0, lpt, -1, lpw, 512);return lpw;}LPTSTR OLE2T(LPCOLESTR lpw){static TCHAR lpt[512];if(!lpw)return NULL;lpt[0] = _T('\0');WideCharToMultiByte(CP_ACP, 0, lpw, -1, lpt, 512, NULL, NULL);return lpt;}void WaitForCompletion(IltmmConvert *pConvert){long lState = ltmmConvert_State_Running;MSG msg;IltmmConvert_get_State(pConvert, &lState);while( lState != ltmmConvert_State_Stopped ){if( PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) ){TranslateMessage(&msg);DispatchMessage(&msg);}IltmmConvert_get_State(pConvert, &lState);}}void CreateDVDImageExample ( ){IltmmConvert *pConvert = NULL;IUnknown *pDvdWriter = NULL;ILTDvdWriter *pIDvdWriter = NULL;BSTR szFileName = NULL;IltmmCompressors *pCompressors;long lIndex = 0;HRESULT hr;CoInitialize(NULL);// create a converter objecthr = CoCreateInstance(&CLSID_ltmmConvert, NULL, CLSCTX_INPROC_SERVER, &IID_IltmmConvert, (void**) &pConvert);// set up the converter:IltmmConvert_put_TargetFormat(pConvert, ltmmConvert_TargetFormat_DVD);IltmmConvert_get_VideoCompressors(pConvert, &pCompressors);hr = IltmmCompressors_Find(pCompressors, L"@device:sw:{33D9A760-90C8-11D0-BD43-00A0C911CE86}\\LEAD MPEG2 Encoder (2.0)", &lIndex);hr = IltmmCompressors_put_Selection(pCompressors, lIndex);IltmmCompressors_Release(pCompressors);IltmmConvert_get_AudioCompressors(pConvert, &pCompressors);hr = IltmmCompressors_Find(pCompressors, L"@device:sw:{33D9A761-90C8-11D0-BD43-00A0C911CE86}\\LEAD MPEG Audio Encoder (2.0)", &lIndex);hr = IltmmCompressors_put_Selection(pCompressors, lIndex);IltmmCompressors_Release(pCompressors);// 1- Create a DVD image with 1 title that contains 1 chapter:szFileName = SysAllocString(T2OLE(MAKE_MEDIA_PATH("DaDa_CMP.avi"))); // Source videoIltmmConvert_put_SourceFile(pConvert, szFileName);SysFreeString(szFileName);szFileName = SysAllocString(T2OLE(MAKE_MEDIA_PATH(""))); // Destination image folderIltmmConvert_put_TargetFile(pConvert, szFileName);SysFreeString(szFileName);IltmmConvert_StartConvert(pConvert);// Wait for the conversion to finish. You can use a window to receive notificationsWaitForCompletion(pConvert);// DoneIltmmConvert_ResetTarget(pConvert);IltmmConvert_ResetSource(pConvert);// 2- Create a DVD image with 1 title that contains 2 chapters:szFileName = SysAllocString(T2OLE(MAKE_MEDIA_PATH("DaDa_CMP.avi"))); // Source videoIltmmConvert_put_SourceFile(pConvert, szFileName);SysFreeString(szFileName);szFileName = SysAllocString(T2OLE(MAKE_MEDIA_PATH(""))); // Destination image folderIltmmConvert_put_TargetFile(pConvert, szFileName);SysFreeString(szFileName);// Retrieve the DVD Writer interfaceIltmmConvert_GetSubObject(pConvert, ltmmConvert_Object_Sink, &pDvdWriter);IUnknown_QueryInterface(pDvdWriter, &IID_ILTDvdWriter, (void**)&pIDvdWriter);// Set the DVD temporary files folderszFileName = SysAllocString(T2OLE(MAKE_MEDIA_PATH(""))); // Destination image folderILTDvdWriter_put_TempPath(pIDvdWriter, szFileName);SysFreeString(szFileName);// Set the TitleBreak property to FALSE.// This will prevent the title from being written immediately after the conversionILTDvdWriter_put_TitleBreak(pIDvdWriter, VARIANT_FALSE);// write the first chapterIltmmConvert_StartConvert(pConvert);// Wait for the conversion to finish. You can use a window to receive notificationsWaitForCompletion(pConvert);// You can change the source file before this step.// This demonstration code uses the same file for all chapters.// Create chapter 2.IltmmConvert_StartConvert(pConvert);WaitForCompletion(pConvert);// Close the titleILTDvdWriter_put_TitleBreak(pIDvdWriter, VARIANT_TRUE);// DoneIUnknown_Release(pDvdWriter);pDvdWriter = NULL;ILTDvdWriter_Release(pIDvdWriter);pIDvdWriter = NULL;IltmmConvert_ResetTarget(pConvert);IltmmConvert_ResetSource(pConvert);// 3- Create a DVD image with 2 titles, each containing 2 chapters:szFileName = SysAllocString(T2OLE(MAKE_MEDIA_PATH("DaDa_CMP.avi"))); // Source videoIltmmConvert_put_SourceFile(pConvert, szFileName);SysFreeString(szFileName);szFileName = SysAllocString(T2OLE(MAKE_MEDIA_PATH(""))); // Destination image folderIltmmConvert_put_TargetFile(pConvert, szFileName);SysFreeString(szFileName);// Retrieve the DVD Writer interfaceIltmmConvert_GetSubObject(pConvert, ltmmConvert_Object_Sink, &pDvdWriter);IUnknown_QueryInterface(pDvdWriter, &IID_ILTDvdWriter, (void**)&pIDvdWriter);// Set the TitleBreak property to FALSE.// This will prevent the title from being written immediately after the conversionILTDvdWriter_put_TitleBreak(pIDvdWriter, VARIANT_FALSE);// Write the first chapter in the first titleIltmmConvert_StartConvert(pConvert);// Wait for the conversion to finish. You can use a window to receive notificationsWaitForCompletion(pConvert);// Write the second chapter in the first title// You can change the source file before this step, this demonstration code uses the same file for all chapters.IltmmConvert_StartConvert(pConvert);WaitForCompletion(pConvert);// Prepare for the second title// Set the TitleBreak property to TRUE, so the current title can be flushedILTDvdWriter_put_TitleBreak(pIDvdWriter, VARIANT_TRUE);// Set the TitleBreak property to FALSE.// This will prevent the title from being written immediately after the conversionILTDvdWriter_put_TitleBreak(pIDvdWriter, VARIANT_FALSE);// Disable Overwrite so the title will be appended to an existing dvd imageILTDvdWriter_put_Overwrite(pIDvdWriter, VARIANT_FALSE);// Write the first chapter in the second titleIltmmConvert_StartConvert(pConvert);// Wait for the conversion to finish. You can use a window to receive notificationsWaitForCompletion(pConvert);// Write the second chapter in the second titleIltmmConvert_StartConvert(pConvert);WaitForCompletion(pConvert);// Close the second titleILTDvdWriter_put_TitleBreak(pIDvdWriter, VARIANT_TRUE);// restore the overwrite propertyILTDvdWriter_put_Overwrite(pIDvdWriter, VARIANT_TRUE);// DoneIUnknown_Release(pDvdWriter);pDvdWriter = NULL;ILTDvdWriter_Release(pIDvdWriter);pIDvdWriter = NULL;IltmmConvert_ResetTarget(pConvert);IltmmConvert_ResetSource(pConvert);IltmmConvert_Release(pConvert);CoUninitialize();}int main(){CreateDVDImageExample ( ) ;return 0;}
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document
