-
AVI Files
Assuming Microsoft hasn't cornered the market with their wonderful Win32 API implementation, what other libraries are out there that can read video (in particular, DV-AVI) files? If the monopoly has taken the ticket, can someone post a no-nonsense bit of code for C++ that simply puts the first frame of an AVI file in a "device context"?
-
Re: AVI Files
I do not have any links for you.
Start with videohelp.com they have sections full of thousands of applications for all sorts of video modding from m2k, ogg, to straight VOB with all the regulars inbetween. Many are open source, I have never looked at more than the few I've needed.
You want to read DVD-AVI or DV-AVI? A spelling error I assume?
You mean the straight VOB files off a DVD? Those files are AVI encodes right?
As for Microsoft cornering this, like I always try and tell people who complain about this sorta stuff. Let them corner it, let them own it 100%, it just gives us more time to figure out its potential, learn how they do it, and often recreate it completly in the end. The Win32 Implimentation...Windows...The whole Windows OS is a marvel of beauty, complain all you want...why do you complain? Its either windows or linux (pretty much). 95% of PC's use windows, if you are a programmer then you WANT THAT!!! Now you can right programs and aim for 95% of an audience with one compile. If we had 100 OS' circulating, with no common bonds but low-end assemble, as programmers and the companies, we'd be behind, slow, and pissed off.
-
Re: AVI Files
Look into the OpenCV library. Among many other functions it can read in AVI frames as a matrix array.
A quick google should give you the relevent info.
-
Re: AVI Files
Thanks for the link, SLH, I'll give it a try.
Cross-platform tends to mean the code is a lot easier to follow (and see, for that matter).
A DV-AVI is an AVI file with a DV video stream in it, from a digital camcorder.
-
Re: AVI Files
Call me an optimist, but I'm sure there's something more well-suited to my needs out there than OpenCV (plus, it completely crashed my computer).
I created this code last night:
Code:
#ifndef __AVI_HPP__
#define __AVI_HPP__
#include <windows.h>
#include <vfw.h>
#include <string>
using namespace std;
class Video {
public:
Video(string path, HDC hdc, int nw);
~Video();
void showFrame(long frame);
private:
PAVIFILE aviFile;
PAVISTREAM aviStream;
AVISTREAMINFO aviStreamInfo;
BITMAPINFOHEADER bmih;
LPBITMAPINFOHEADER lpbi;
PGETFRAME pgf;
HBITMAP hBitmap;
unsigned char* data;
char *pdata;
HDRAWDIB hdd;
HDC drawdc;
int width, height, newwidth, newheight;
};
Video::Video(string path, HDC hdc, int nw) {
AVIFileInit();
AVIFileOpenA(&aviFile, path.c_str(), OF_READ, NULL);
AVIFileGetStream(aviFile, &aviStream, streamtypeVIDEO, 0);
AVIStreamInfo(aviStream, &aviStreamInfo, sizeof(aviStreamInfo));
width = aviStreamInfo.rcFrame.right - aviStreamInfo.rcFrame.left;
height = aviStreamInfo.rcFrame.bottom - aviStreamInfo.rcFrame.top;
bmih.biSize = sizeof(BITMAPINFOHEADER);
bmih.biPlanes = 1;
bmih.biBitCount = 24;
bmih.biWidth = width;
bmih.biHeight = height;
bmih.biCompression = BI_RGB;
pgf = AVIStreamGetFrameOpen(aviStream, NULL);
data = 0;
hBitmap = CreateDIBSection(hdc, (BITMAPINFO*)(&bmih), DIB_RGB_COLORS,
(void**)(&data), NULL, 0);
SelectObject(hdc, hBitmap);
drawdc = hdc;
hdd = DrawDibOpen();
newwidth = nw;
newheight = nw * (height / width);
}
Video::~Video() {
DrawDibClose(hdd);
AVIStreamGetFrameClose(pgf);
AVIFileRelease(aviFile);
AVIFileExit();
}
void Video::showFrame(long frame) {
lpbi = (LPBITMAPINFOHEADER)AVIStreamGetFrame(pgf, frame);
pdata = (char*)(lpbi + lpbi->biSize + lpbi->biClrUsed * sizeof(RGBQUAD));
DrawDibDraw (hdd, drawdc, 0, 0, newwidth, newheight,
lpbi, pdata, 0, 0, width, height, 0);
}
#endif
Anyone care to shed some light on the whole... crashing issue? And when I say created... I do mean assembled from the 3 places the 'net has to offer on this.
-
Re: AVI Files
On this page, you can find some VB examples on how to deal with avi files. They might help you...