开发者

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

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.

Closed 7 years ago.

Improve this question 开发者_Python百科

I have a program that creates frame buffers in OpenGL. I can save out the buffers as .png or as .jpg files, and I am familiar with some utilities on Windows (like http://www.radgametools.com/bnkmain.htm) that will convert multiple image files to .mpg

But I would like an open source library to call with my buffer already in RAM. Does such an API exist?


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);
}


ffmpeg's libavcodec is probably a good place to start.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜