|
Is there a place to get/view some c++ code, concerning the avifile-api?
msdn is not helping here, cause it misses some pages about the topic (avistreamwrite is missing...).
It appears that the codec for div-x avifiles cannot be used, returns no codec for ICOPEN on a div-x avistream. correct?
[VISUAL STUDIO 6.0] [MFC] [WIN98/2]
Bluute tette!
|
|
|
|
|
frisco wrote:
Is there a place to get/view some c++ code, concerning the avifile-api?
msdn is not helping here, cause it misses some pages about the topic (avistreamwrite is missing...).
When I wrote my last AVI code I used MSDN, but it is a little lacking, so I had to experiment a lot to get it working.
frisco wrote:
It appears that the codec for div-x avifiles cannot be used, returns no codec for ICOPEN on a div-x avistream. correct?
I have used both the DIVX v3 and v4 codecs to encode AVI files without any problems. I am planning to submit an article about video encoding here as soon as I get a chance.
Here's some code that I used to enumerate codecs, display codec info, and open the codec's config dialog. It works with all codecs I have tested it with, including DIVX v3 and v4.
BOOL CPPVideoDestOptionsCompression::PopulateCompressors()
{
BITMAPINFO bitmap;
CAPTUREPROFILE captureProfile;
// Show status dialog
CDlgStatus *pDlg = new CDlgStatus;
pDlg->Create(IDD_STATUS);
pDlg->SetStatusText("Looking for video compressors...");
pDlg->Invalidate();
pDlg->ShowWindow(SW_SHOW);
CCapture::GetCurrentProfile(&captureProfile);
// Zero bitmap info header
ZeroMemory((PVOID)&bitmap, sizeof(BITMAPINFO));
// Load screen info
HDC hdcScreen;
hdcScreen = ::GetDC(NULL);
bitmap.bmiHeader.biWidth = 20;
bitmap.bmiHeader.biHeight = 20;
bitmap.bmiHeader.biBitCount = ::GetDeviceCaps(hdcScreen, BITSPIXEL);
bitmap.bmiHeader.biPlanes = ::GetDeviceCaps(hdcScreen, PLANES);
::ReleaseDC(NULL, hdcScreen);
int compressorNumber = 0;
int nSelectedCompressor = 0;
ICINFO compressorInfo;
for(int i = 0; i < 30;i++) {
ICInfo(ICTYPE_VIDEO, i, &compressorInfo);
HIC hic;
hic = ICOpen( compressorInfo.fccType,
compressorInfo.fccHandler,
ICMODE_QUERY);
if (hic) {
if (ICCompressQuery(hic, &bitmap, NULL) == ICERR_OK) {
if (ICGetInfo(hic, &compressorInfo, sizeof(ICINFO))) {
// Add to combo box
char szName[16];
WideCharToMultiByte( CP_ACP,
0,
compressorInfo.szName,
-1,
szName,
16,
NULL,
NULL);
int pos = m_cboxVideoCompressor.AddString(szName);
TRACE("CPPVideoDestOptionsCompression::PopulateCompressors() - Adding %s...\n", szName);
// Add it to the list
m_CompressorInfo[compressorNumber] = compressorInfo;
// Is this the one in the profile?
if (compressorInfo.fccHandler == captureProfile.dwVideoFCCHandler)
nSelectedCompressor = pos;
// Next compressor, please!
compressorNumber++;
}
}
m_cboxVideoCompressor.SetCurSel(nSelectedCompressor);
ICClose(hic);
}
}
if (compressorNumber == 0) {
MessageBox("There are no video compressors installed that are compatible with your current display settings.",
APP_NAME, MB_ICONINFORMATION|MB_TOPMOST);
m_cboxVideoCompressor.EnableWindow(FALSE);
GetDlgItem(IDC_BTN_VIDEO_DEST_OPT_COMPRESSION_COMP_INFO)->EnableWindow(FALSE);
GetDlgItem(IDC_BTN_VIDEO_DEST_OPT_COMPRESSION_COMP_SETTINGS)->EnableWindow(FALSE);
GetDlgItem(IDC_STC_VIDEO_DEST_OPT_COMPRESSION_COMP_NUMBER)->SetWindowText("No compressors found.");
m_sliderVideoQuality.EnableWindow(FALSE);
m_sliderDataRate.EnableWindow(FALSE);
} else {
CString foo;
foo.Format("Found %d video %s.", compressorNumber,
(compressorNumber) > 1 ? "codecs" : "codec");
GetDlgItem(IDC_STC_VIDEO_DEST_OPT_COMPRESSION_COMP_NUMBER)->SetWindowText(foo);
}
pDlg->DestroyWindow();
delete pDlg;
return TRUE;
}
void CPPVideoDestOptionsCompression::OnSelchangeVideoCompressor()
{
// TODO: Add your control notification handler code here
int nSelectedCompressor;
nSelectedCompressor = m_cboxVideoCompressor.GetCurSel();
if (nSelectedCompressor != CB_ERR) {
// Open the current compressor
HIC hic;
hic = ICOpen( mmioFOURCC('V','I','D','C'),
m_CompressorInfo[nSelectedCompressor].fccHandler,
ICMODE_QUERY);
// Did it open ok?
if (hic == 0) {
CString foo;
char szName[16];
WideCharToMultiByte( CP_ACP,
0,
m_CompressorInfo[nSelectedCompressor].szName,
-1,
szName,
16,
NULL,
NULL);
foo.Format("Could not query compressor for existence of configuration dialog:\r\n%s", szName);
MessageBox(foo, APP_NAME, MB_ICONSTOP|MB_TOPMOST);
}
// Does this compressor have a configuration dialog?
if (ICQueryConfigure(hic) != ICERR_OK) { // Weird
GetDlgItem(IDC_BTN_VIDEO_DEST_OPT_COMPRESSION_COMP_CONFIG)->EnableWindow(TRUE);
GetDlgItem(IDC_BTN_VIDEO_DEST_OPT_COMPRESSION_COMP_RESET)->EnableWindow(TRUE);
} else {
GetDlgItem(IDC_BTN_VIDEO_DEST_OPT_COMPRESSION_COMP_CONFIG)->EnableWindow(FALSE);
GetDlgItem(IDC_BTN_VIDEO_DEST_OPT_COMPRESSION_COMP_RESET)->EnableWindow(FALSE);
}
// Close compressor
ICClose(hic);
// Update configuration
CPSVideoDestOptions::m_CaptureProfile.dwVideoFCCHandler =
m_CompressorInfo[nSelectedCompressor].fccHandler;
}
}
void CPPVideoDestOptionsCompression::OnBtnVideoCompInfo()
{
// Open the selected compressor
HIC hic;
int nSelection;
nSelection = m_cboxVideoCompressor.GetCurSel();
hic = ICOpen( m_CompressorInfo[nSelection].fccType,
m_CompressorInfo[nSelection].fccHandler,
ICMODE_QUERY);
// Did we open it?
if (hic != 0) {
// Does this compressor have an "about" box?
if (ICAbout(hic, -1) == ICERR_OK) {
ICAbout(hic, GetSafeHwnd());
} else {
MessageBox( "No compressor information is available.",
APP_NAME,
MB_ICONINFORMATION|MB_TOPMOST);
}
// Close the compressor
ICClose(hic);
}
}
void CPPVideoDestOptionsCompression::OnCompConfig()
{
// Get the currently selected compressor
int nSelectedCompressor;
nSelectedCompressor = m_cboxVideoCompressor.GetCurSel();
// Is there a compressor selected
if (nSelectedCompressor == CB_ERR) {
return;
}
// Open the current compressor
HIC hic;
hic = ICOpen( mmioFOURCC('V','I','D','C'),
m_CompressorInfo[nSelectedCompressor].fccHandler,
ICMODE_QUERY);
// Did it open ok?
if (hic == 0) {
CString foo;
char szName[16];
WideCharToMultiByte( CP_ACP,
0,
m_CompressorInfo[nSelectedCompressor].szName,
-1,
szName,
16,
NULL,
NULL);
foo.Format("Could not open compressor:\r\n%s", szName);
MessageBox(foo, APP_NAME, MB_ICONSTOP|MB_TOPMOST);
return;
}
// Do we already have a save state for this compressor?
DWORD dwStateBytes;
BYTE *pState = NULL;
if (::CompressorLoadState(&m_CompressorInfo[nSelectedCompressor], NULL, &dwStateBytes)) {
pState = new BYTE[dwStateBytes];
// Yes, so load our saved state
if (::CompressorLoadState(&m_CompressorInfo[nSelectedCompressor], (LPVOID*)&pState, &dwStateBytes)) {
// Loaded it, now set it
ICSetState(hic, (LPVOID)pState, dwStateBytes);
}
delete[] pState;
}
// Display codec configuration dialog
ICConfigure( hic,
GetSafeHwnd());
// Get amount of space for compressor options
DWORD nStateBytes;
nStateBytes = ICGetStateSize(hic);
// Allocated the space
pState = new BYTE[nStateBytes];
// Get the current state
ICGetState( hic,
(PVOID)pState,
nStateBytes);
// Close the compressor
ICClose(hic);
// Save state to file
if (!CompressorSaveState(&m_CompressorInfo[nSelectedCompressor], pState, nStateBytes)) {
MessageBox("Error saving compressor state.", APP_NAME, MB_ICONSTOP|MB_TOPMOST);
}
// Free state memory
delete[] pState;
}
Wow, that's a long message!
--
Dana Holt
Xenos Software
|
|
|
|
|
A long message indead, and a helping one too!
Experimenting because you don't find any doc on the net, that's what I'm doing here all the time
I'm certainly gonna check you code, but could that div-x problem have something to do with that new div-x/playa thing?
[VISUAL STUDIO 6.0] [MFC] [WIN98/2]
Bluute tette!
|
|
|
|
|
frisco wrote:
I'm certainly gonna check you code, but could that div-x problem have something to do with that new div-x/playa thing?
I don't think the divx playa would cause you any codec problems but anything is possible.
I also saw that DIVX5 is out now from www.divx.com.
--
Dana Holt
Xenos Software
|
|
|
|
|
An article on that topic would be nice
In fact, I'm a java-programmer (but I've learned turbo c++ at school some years ago). And I was able to write a program in java that did the basic video/audio editing in less than half a day. That's because the sources for java are much more available, starting with the site from sun microsystems that's way better than the msdn antipode.
I think this is the problem for c++: you can't find anything, have to experiment all the time.
[VISUAL STUDIO 6.0] [MFC] [WIN98/2]
Bluute tette!
|
|
|
|
|
frisco wrote:
An article on that topic would be nice
I have the code working. I need to put it into a class, tidy it up, and add support for an audio stream to be encoded into the AVI.
frisco wrote:
I think this is the problem for c++: you can't find anything, have to experiment all the time.
C/C++ lets you do so much that you can get into trouble quickly. For example, writing/reading through bad pointers. I started with C and assembly language under DOS, so I have learned to avoid these pitfalls most of the time.
Some parts of the Windows API docs are very lacking or even misleading. This is what causes me most of my frustration these days.
--
Dana Holt
Xenos Software
|
|
|
|
|
I've found something else.
The AVISTREAMINFO returns DIV4 for fcctype but the BITMAPINFOHEADER returns DIV3 for compressor. I guess that's normal?
[VISUAL STUDIO 6.0] [MFC] [WIN98/2]
Bluute tette!
|
|
|
|
|
frisco wrote:
I've found something else.
The AVISTREAMINFO returns DIV4 for fcctype but the BITMAPINFOHEADER returns DIV3 for compressor. I guess that's normal?
That is weird. I have never done any decoding, so I have no idea what kind of horrors to expect.
What function are you using to get this information loaded into BITMAPINFOHEADER?
--
Dana Holt
Xenos Software
|
|
|
|
|
BITMAPINFOHEADER bi;
AVIStreamReadFormat(pStream,0,&bi,&lStreamSize);
[VISUAL STUDIO 6.0] [MFC] [WIN98/2]
Bluute tette!
|
|
|
|
|
NE1 know where I can find a class/implemenation of a keyboard that can be popped up for entry into an app?
Thanks
|
|
|
|
|
I'm writing an addin and i want it to obtain the path of the workspace file on "closing the workspace" event.
How should i get it?
rechi
|
|
|
|
|
What should i do to make this work:
bool running=true;
void CXDlg::OnCancelButton() {
running=false;
}
void CXDlg::OnStartButton() {
while (running) {
//if i'm running this loop i cannot
//click on the cancel button (in fact
//i can but it doesn't work )
}
}
If you know VB you know that there is a function called DoEvents(). But i can't find somethig like that in C. Please help if you can.
Thanks
Vis
|
|
|
|
|
You should place the loop in a separate worker thread, otherwise you'll normaly block the message loop and the cancel message will never be treated.
rechi
|
|
|
|
|
And how can i create a new thread?
Vis
|
|
|
|
|
Use AfxBeginThread. Pass a thread function and create a meessage loop inside of it. Then use PostThreadMessage to communicate with the thread.
rechi
|
|
|
|
|
You should give the UI chance to process the mesgs.
Put the foll. function in your app and call it
in the loop.
void CMyApp::ProcesssQueuedMsgs()
{
MSG msg ;
// User tries to close the application during a lengthy process causes a crash,
// (The window object are destroyed when this mesg is processed) so exclude WM_CLOSE.
while( PeekMessage(&msg, NULL,0,0,PM_NOREMOVE) && msg.message != WM_CLOSE )
{
AfxGetApp ()->PumpMessage () ;
}
LONG lIdle = 0;
while (AfxGetApp ()->OnIdle (lIdle++));
}
In OnCancel()
set the 'running' to false and the code will work.
|
|
|
|
|
This should be the best way rather than spwning a new thread.
|
|
|
|
|
Thx for the comment, that is more than what I can say for the
fellows who r actually using this code and dont bother with
a reply.
|
|
|
|
|
Sorry but i use internet in school and we had a holiday from Saturday to Wednesday so i could not send any messages to you (or even to read them).
But now i can so thanks for all!
Vis
|
|
|
|
|
|
Sorry, but i could not even read your messages because i was on holiday for a few days and i hadn't got any computer or else to use the net.
But now i have so i say thanks for you all: Thanx!
Vis
|
|
|
|
|
I have SDI, when I resize it or non Active.. all will be clear as new document. Help me,how to save it???
|
|
|
|
|
What do u mean all will be clear ?
Do u mean that ur view is getting erased ?
|
|
|
|
|
Draw dot, and type text... more
|
|
|
|
|
Hi,
I´m running Ms Word Automated, when I run my program I show that word document inside my framework, the problem comes when the user wants to load a document, I would like that the user could be able to load the doc in the same window that is open ( not what Ms Word makes open a new Word Window, for the new opened file ).
How can I do that ?, Thanks in advance, Greetings
Braulio
|
|
|
|
|