I need to write a small software that will show video. I don't know any thing about graphics at C.
What classes are there? Please point me to a place to start from.
Thanks, Nahum
I don't know any thing about graphics at C
I strongly suggest you learn this first otherwise you'll have a hard time doing it.
Anyway: writing a well performing video player is no small feat. Luckily there are readily usable multimedia packages for Linux:
All of these can be embedded into your own program. Personally I recommend either libxine or the ffmpeg libraries, as those are the IMHO most solid and straightforward to use. GStreamer looks nice on the paper, but has problems with stability (in my experience).
For just the display of video-frames with a fixed timing interval, your easiest bet is to probably use a nice graphics toolkit like Qt. This will provide you the tools necessary to have a timer, paint video to the screen, etc.
If you are planning on decoding compressed video sources like H.264, MPEG-2, etc., you will want to look into the Qt Phonon multimedia framework, directly use GStreamer, or possibly use the ffmpeg libraries to decompress the video streams and then paint them to the screen with your player's framework.
Another simple library to use to display video is OpenCV (cross-platform):
int main(int argc, char** argv)
{
cvNamedWindow("xsample", CV_WINDOW_AUTOSIZE);
CvCapture* capture = cvCreateFileCapture("movie.avi");
if (!capture)
{
printf("!!! cvCreateFileCapture didn't found the file !!!\n");
return -1;
}
IplImage* frame;
while(1)
{
frame = cvQueryFrame( capture );
if (!frame)
break;
cvShowImage( "xsample", frame );
char c = cvWaitKey(33);
if (c == 27)
break; // ESC was pressed
}
cvReleaseCapture(&capture);
cvDestroyWindow("xsample");
return 0;
}
And that's it. However, you won't be able to play sound with OpenCV, just video. But if you are looking for a workaround on that, here is a little something I wrote some time ago using OpenCV and FFmpeg.