OPENCV Read avi

Source: Internet
Author: User

Today see a lot of people on the Internet ask, Cvcreatefilecapture read AVI, why always return null. I checked the literature, summed up as follows: (source program attached to the bottom)
Question: Why does my Computer support AVI or can broadcast AVI, but why use the Cvcreatefilecapture function to always return null? Answer: Although it is an AVI file, it is possible to use some kind of codec, such as: MJPEG decompressor. Need to convert it to OPENCV supported AVI files. The OPENCV supports AVI as follows:

Container

FourCC

Name

Description

Avi

' DIB '

RGB (A)

Uncompressed RGB, or bit

Avi

' I420 '

RAW I420

Uncompressed YUV, 4:2:0 chroma subsampled

Avi

' iYUV '

RAW I420

Identical to I420


Conversion format Workaround: Workaround 1: Download Mencoder.exe, use under Window command line: mencoder IN.AVI-OVC raw-vf Format=i420-o Out.avi (Note: I tested this method, did not succeed, reason unknown , I hope some friends can discuss it in detail. )
Workaround 2: Download Vitualdub, I use 1.9.4 version A. File->open video File; B. video->filters->add->convert format; Select 4:2:0 Planar YCbCr (YV12) or 32-bit RGB. C. Save as AVI. Save complete. (Note: successful use.) )
We can test it. If still not, please reply and discuss together.

My source code, (VS C + + 2008 Expression, WinXP SP3,)//----------------------------------------------------------------------- -------------------------

#include "stdafx.h" #include <iostream> #include <cv.h> #include <cxcore.h> #include iplimage* frame; Cvnamedwindow ("PlayAVI", cv_window_autosize); while (1) {frame = Cvqueryframe (capture ); if (!frame) break;
Cvshowimage ("PlayAVI", frame);          key = Cvwaitkey ()//Quit when users press ' ESC ' if (key = =) break; } cvreleasecapture (&capture); Cvdestroywindow ("PlayAVI"); 
return 0;} from http://hq.huang.blog.163.com/blog/static/ 1066821912009758958885/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.