Hi, Ashwath. If you are allowed to use ffmpeg in your project then the solution code becomes trivial. Else you will need to check the documentation for the ICDecompress function. You are using the win32 apis to load your avi file, they are very slow and require you to use COM interfaces to decompress your files - these rely on installed codecs on your machine. Using ffmpeg gives you a solution which comes with its codecs built right into the library. Hope this helps.
Hi, it is possible to do this using both methods:, but it is easier using ffmpeg. I would recommend you Google ffmpeg and check their examples, you could accomplish your task in about 60 lines of code. Happy coding
Thanks for ur suggestion.I have two AVI files.One is compressed and the other is uncompressed.I want to extract the frames from both the AVI files.Will the FFMPEG library work for both compressed and uncompressed AVI files?
Hi Ashwath, the FFMPEG library will work for both files. As a side note, the library comes with pre built executables which you could use to immediately extract the frames you need, there are tons of articles online about how to do this - just download the library an programs from here and check their online documentation for the parameters you need to extract the frames.
Actually what i am doing is that i have created a MFC dialog based GUI.And i want to extract the frame buffer from the compressed AVI file by decompressing it first and then copying the buffer values to unsigned char array and display on a picture control as a bitmap image.And i want to extract all the files in the compressed AVI file in this way and display one by one on the picture control on the MFC GUI.
You can get an image from the avi stream using ffmpeg, into an av_picture structure, then use the libswscale functions to scale and convert the image into different resolutions or formats, and finally draw the buffer to a control on your mfc gui. You should really Google for code samples.
Normally, the CMainFrame object is constructed in the InitInstance method using the call -
pDocTemplate = new CSingleDocTemplate(
RUNTIME_CLASS(CMainFrame), // main SDI frame window
Do you see this call in InitInstance?
If you don't see this, it means that the construction is being done elsewhere; your app class constructor perhaps.
If you do see the above code and you still have the behavior you mentioned, it could mean that some other CMainFrame instance is being constructed.
Whatever the case, it is not the correct way to do it.
«_Superman_» I love work. It gives me something to do between weekends.
Hi guys, I'm using WinHttp in a regular Win32 app (Windows SDK in C++, no MFC) and I want to prevent automatic redirects. The only thing I could find is WinHttpRequestOption but I have no idea how to set that or if that's what I need to do.
I want my code to check for a redirect before proceeding.
This fix applies to VS2012 MFC projects that use the Windows7 Visual Manager style. It causes active button caption text to draw in color 0,0,0 and not the same color as inactive.
This restores VS2010/2008 Feature Pack behavior.
Hello, I thought to post this to CP in case others had this issue. In 2012 MFC was 'fixed' to draw text using TextNormal as specified in Style.xml resource (I suspect that TextNormal should have been 0,0,0 in 2010 but it went unoticed).
People, I found that CFileDialog class causes serious problem.
I had a large free memory block in the address space of my prog: 1200 MB
Then I create CFileDialog and delete it:
CFileDialog *pdlg=new CFileDialog(TRUE);
I check address space again and found only 700 MB:
The reason was very simple: I found some dlls in the address space of my process like urlmon.dll, netapi.dll, modemInst.dll and so on. These dlls was loaded into my address space by CFileDialog class and was not unloaded by its destructor. As a result, I couldn't allocate memory for a large file- address space had been fragmented. Any idea how to solve this situation? I think to create CFileDialog in a separate process. May be, there are better variants?
[quote]If you're sure the memory is being taken up by those dlls, why not try unloading them yourself with
How are you trying to allocate the memory? Have you tried the VirtualAlloc() function?[/quote]
Yeah, I'm sure because I saw list of modules, downloaded in the address space before creation of CFileDialog and after it had been destructed. I tried to use FreeLibrary for such modules. After it (not immediately) program failed, giving me some inaudible error messages. Yeah, I used VirtualAlloc(). It is the best if you need to allocate large memory block. Currently I created a new process, which works with CFileDialog, leaving my address space untouched. It works, but I think that it is not very elegant approach. And one mysterious dll still presents- modemInst.dll (it is not connected with CFileDialog).
A program using DLLs may delay loading them unto the point when they're first needed. This appears to have happened here. The problem with that is that the DLLs will then stay until you exit your program, or manually unload them (as suggested above).
Why CFileDialog loads all these DLLs isn't clear to me. My guess would be file preview settings - but then I would have thought the DLLs used for previewing would be loaded to system memory, not application memory. Anyway, this is not in fact a memory leak, "only" a shortage of memory.
Moreover, you should normally not even be able to notice memory fragmentation, except for the fact that the operators new and delete notably slow down when you're low on memory. The system memory manager hides the true physical memory addresses from you, and translates them to a virtual application memory address space. So even if you get addresses from allocations that indicate a state of fragmentation, this may be misleading.
That said, the memory manager will easily allocate huge blocks of memory for you even if fragmentation does split up your memory into unusably small chunks: it has the ability to pretend a contiguous block of memory, even if the physical memory is spread out all over the entire available physical memory space.
Your problem is a different one however: you cannot load a large file into memory as a whole. that means your application is using more memory than available. Note that even with 16 GB RAM, the memory space of an application is limited to no more than 4 GBm or in Windows in fact only about 2-3 GB, depending ont the OS version.
The solution is to split it up. It isn't a good idea to load such big files into memory anyway - exactly because of the problem you encountered. Depending on what you wish to do with that file, you don't need the full file at any point in time anyway. Instead use a buffer of at most a few MB in size, load a chunk, process the data, store the intermediary results, then repeat until you're done.
To unload libraries which you did not load is unsafe op- just as Stephen wrote. try delete twice the same object and you'll see what will happen. To perform this op, one has to know how they were loaded and unload them exact in opposite order. Moreover, he must know, that nobody else will try to unload these libraries too. I tried, and program failed. CFileDialog loads all these libraries for the very simple reason. It offers such service: one may open file from remote disk for example (or you may type an URL in address bar). Dear Stefan, you are not right about memory manager. I do not see physical addresses, but only virtual ones. In my virtual address space I have to have a continuous block of free memory in virtual address space to allocate large file (and no matter, what I use- VirtualAlloc, new or MapViewOfFile). I can clearly see fragmentation of my address space, when I run my prog under debugger. As I wrote, I had 1.2 GB continuous block before creation of CFileDialog and only 0.7 GB after it. If I can to download large file, I will do it. To split file is the last chance. Any idea, what headache will I have, if for example I need to rotate large file, which cannot be downloaded in memory?
Last Visit: 31-Dec-99 19:00 Last Update: 11-Dec-23 12:56