3

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

nmnir
  • 568
  • 1
  • 10
  • 24

3 Answers3

2

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:

  • libxine
  • ffmpeg libraries (libavformat, libavdevice, libavcodec and libswscale) -- used by mplayer
  • VLC
  • GStreamer

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).

datenwolf
  • 159,371
  • 13
  • 185
  • 298
2

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.

Jason
  • 31,834
  • 7
  • 59
  • 78
2

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.

Community
  • 1
  • 1
karlphillip
  • 92,053
  • 36
  • 243
  • 426
  • Thanks. How can I use OpenCV to show frame by frame (which I receive using UDP)? – nmnir Dec 07 '11 at 14:09
  • What do you want to do? Display a video file, display video from a camera on your network, or display some sort of [video stream coming from your network](http://nashruddin.com/Streaming_OpenCV_Videos_Over_the_Network)? But the first step is retrieve the data stream from this connection and convert it to useful OpenCV data (`IplImage`). – karlphillip Dec 07 '11 at 15:04