How to convert jpg to avi file?


I developed code below to convert jpeg to avi, but it does not work.
Could you help me?

hr = AVIFileOpen(&pFile, file_name, OF_WRITE | OF_CREATE, 0);

strhdr.fccType = streamtypeVIDEO;
strhdr.fccHandler = 0;
strhdr.dwScale = 10;
strhdr.dwRate = 1000;
strhdr.dwSuggestedBufferSize = cbImage;
SetRect(&strhdr.rcFrame, 0, 0, newX, newY);
hr = AVIFileCreateStream(pFile, &ps, &strhdr);

opts.fccHandler=mmioFOURCC('D','I','B',' ');
hr = AVIMakeCompressedStream( &psCompressed, ps, &opts, 0);

bitmapheader.biWidth = newX ;
bitmapheader.biHeight = newY;
bitmapheader.biPlanes = 1;
bitmapheader.biBitCount = 24;
bitmapheader.biSizeImage = cbImage;
bitmapheader.biSize = bfSize;
hr = AVIStreamSetFormat(psCompressed, 0, &bitmapheader, headersize);

hr = AVIStreamWrite( psCompressed, 0, 1, ptImg, cbImage, AVIIF_KEYFRAME, 0, 0);

hr = AVIStreamRelease(psCompressed);

hr = AVIStreamRelease(ps);

hr = AVIFileRelease(pFile);
You want to create an AVI file consisting of a single frame, and the source image of that frame is a JPEG file? Is that right?
I think you just decompose the jpg back to logically a "2-d" image of pixels (these are usually just a unsigned char * in code) in insert that as a frame (X however long you want to show it, may require inserting same frame many times).
Last edited on
Registered users can post here. Sign in or register to post.