Now all we need to do is make the SaveFrame function to write the RGB information to a file in PPM format. RGB information is written to a file in PPM format We e going to be kind of sketchy sketchy on the PPM format itself ; trust us, it works.
/ / Find the first video stream
/ / Determine required buffer size and allocate buffer
AVFormatContext § * pFormatCtx;
fwrite (pFrame-> data [0] y * pFrame-> linesize [0], 1, width * 3, pFile);
if (frameFinished) {
sprintf (szFilename, “frame% d.ppm”, iFrame) ;
(AVPicture § *) pFrame, pCodecCtx-> pix_fmt,
you will notice that we use av_free to release we use avcode_alloc_fram and av_malloc to allocate memory.
10 to open the file from the video streaming video.avi video_stream
/ / Allocate an AVFrame structure
}
fclose (pFile);
return -1; / / Codec not found
pCodec = avcodec_find_decoder (pCodecCtx-> codec_id);
avcodec_close (pCodecCtx);
char szFilename [32];
Basically, streaming video and audio processing is easy:
/ / Assign appropriate parts of buffer to image planes planes in pFrameRGB
Now we can actually open the file:
if (avcodec_open § (pCodecCtx, pCodec) <0) < br /> AVFormatContext * pFormatCtx;
>> Tutorial 2: Outputting to the Screen §
return;
int i;
numBytes = avpicture_get_size (PIX_FMT_RGB24, pCodecCt x-> width,
av_free (pFrameRGB);
/ / Save the frame to disk
Tutorial 01: Making Screencaps creation screen video http://home.chinavideo.org/space.php?uid=1