C++:What's the Easiest Library to Open Video File

C++ : What's the easiest library to open video file

Currently these are the most popular video frameworks available on Win32 platforms:

  1. Video for Windows: old windows framework coming from the age of Win95 but still widely used because it is very simple to use. Unfortunately it supports only AVI files for which the proper VFW codec has been installed.

  2. DirectShow: standard WinXP framework, it can basically load all formats you can play with Windows Media Player. Rather difficult to use.

  3. Ffmpeg: more precisely libavcodec and libavformat that comes with Ffmpeg open- source multimedia utility. It is extremely powerful and can read a lot of formats (almost everything you can play with VLC) even if you don't have the codec installed on the system. It's quite complicated to use but you can always get inspired by the code of ffplay that comes shipped with it or by other implementations in open-source software. Anyway I think it's still much easier to use than DS (and much faster). It needs to be comipled by MinGW on Windows, but all the steps are explained very well here (in this moment the link is down, hope not dead).

  4. QuickTime: the Apple framework is not the best solution for Windows platform, since it needs QuickTime app to be installed and also the proper QuickTime codec for every format; it does not support many formats, but its quite common in professional field (so some codec are actually only for QuickTime). Shouldn't be too difficult to implement.

  5. Gstreamer: latest open source framework. I don't know much about it, I guess it wraps over some of the other systems (but I'm not sure).

All of this frameworks have been implemented as backend in OpenCv Highgui, except for DirectShow. The default framework for Win32 OpenCV is using VFW (and thus able only to open some AVI files), if you want to use the others you must download the CVS instead of the official release and still do some hacking on the code and it's anyway not too complete, for example FFMPEG backend doesn't allow to seek in the stream.
If you want to use QuickTime with OpenCV this can help you.

Any cross-platform video playback library for c++?

I found the Theora playback library to be very useful and only depends on the original theora library. Here is a simple Qt project I made that encapsulate everything needed to play (only video) theora media. You just type 'qmake' and you are good to go.

.NET Library for reading video frames

You might want to take a look at Microsoft's IMediaDet interface, specifically the GetBitmapBits and WriteBitmapBits methods.

This article on CodeProject deomonstrates:

Extract Frames from Video Files

C library to build video directly from buffers on Linux, preferably portable to Windows and Mac OS X

Since you are looking for a library, I suggest taking a look at OpenCV (it's cross-platform library supported on Windows/Linux/Mac).

I've written the code below some time ago. It loads two JPG images from the current directory and creates a video file with it. I believe it's more than enough to get you started.

#include <cv.h>
#include <highgui.h>

int main()
{
IplImage* img1 = cvLoadImage("img1.jpg", CV_LOAD_IMAGE_UNCHANGED);
IplImage* img2 = cvLoadImage("img2.jpg", CV_LOAD_IMAGE_UNCHANGED);

float fps = 20;
CvVideoWriter* writer = cvCreateVideoWriter("out.avi", CV_FOURCC('M','J','P','G'), fps, cvGetSize(img1), true);
if (!writer)
{
fprintf (stderr, "VideoWriter failed!\n");
return -1;
}

cvWriteFrame(writer, img1);
cvWriteFrame(writer, img2);

cvReleaseVideoWriter(&writer);
cvReleaseImage(&img1);
cvReleaseImage(&img2);
}


Related Topics



Leave a reply



Submit