Results 1 to 6 of 6

Thread: AVI Files

  1. #1

    Thread Starter
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134

    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"?
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  2. #2
    PowerPoster Halsafar's Avatar
    Join Date
    Jun 2004
    Location
    Saskatoon, SK
    Posts
    2,339

    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.
    "From what was there, and was meant to be, but not of that was faded away." - - Steve Damm

    "The polar opposite of nothingness is existance. When existance calls apon nothingness it shall return to nothingness." - - Steve Damm

    "When you do things right, people won't be sure if you did anything at all." - - God from Futurama

  3. #3
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051

    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.
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  4. #4

    Thread Starter
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134

    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.
    Last edited by Sastraxi; May 2nd, 2005 at 04:35 PM.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  5. #5

    Thread Starter
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134

    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.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  6. #6
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755

    Re: AVI Files

    On this page, you can find some VB examples on how to deal with avi files. They might help you...
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width