the Swscale in FFmpeg provides the video raw data (Yuv420,yuv422,yuv444,rgb24 ... Conversion, resolution transformation and other operations, it is very convenient to use, here to record its usage. The Swscale is primarily used to convert between 2 avframe. Here is a simple video decoding example, this program completed the "Beijing Mobile Developer Conference Coffee break Video 2.flv" (In fact, Youku, a normal video) decoding work, and to save the decoded data as the original data files (such as YUV420,YUV422,RGB24, etc.). It omits a lot of code. Note: Complete code in the article: 100 lines of code to implement the simplest ffmpeg+sdl based video player
[CPP] View Plain copy//ffmpeg simple player // //Media Resources Retrieval System subsystem // //2013 lei Hua leixiaohua1020@126.com //Communication University/Digital TV // # include "stdafx.h" int _tmain (int argc, _tchar* argv[]) { AVFormatContext *pFormatCtx; int i, videoindex; AVCodecContext *pCodecCtx; avcodec *pcodec; char filepath[]= "Beijing Mobile developer Conference tea break Video 2.flv"; av_register_all (); avformat_network_init (); pformatctx = avformat_ AlLoc_context (); if (Avformat_open_input (&pformatctx,filepath,null,null)! = 0) { printf ("Cannot open file \ n"); return -1; } ...... AVFrame *pFrame,*pFrameYUV; pframe=avcodec_alloc_frame (); pframeyuv=avcodec_alloc_frame (); uint8_ t *out_buffer; out_buffer=new uint8_t[avpicture_get_size (pix_fmt_rgb24, pcodecctx->width, pcodecctx->height)];    avpicture_fill ((avpicture *) pframeyuv, out_buffer, pix_ Fmt_rgb24, pcodecctx->width, pcodecctx->height); /* out_buffer=new uint8_t[avpicture_get_size (pix_fmt_yuv420p, pcodecctx-> Width, pcodecctx->height)]; avpicture_fill ( avpicture *) pframeyuv, out_buffer, pix_fmt_yuv420p, pcodecctx->width, pcodecctx- >height);*/ /* out_buffer=new uint8_t[avpicture_get_size (pix_fmt_uyvy422, pcodecctx->width, pcodecctx->height)]; avpicture_fill (avpicture *) PFrameYUV, out_buffer, pix_fmt_uyvy422, pcodecctx->width, pcodecctx->height); Out_buffer=new uint8_t[avpicture_get_size (pix_fmt_yuv422p, pcodecctx->width, pcodecctx-> Height)]; avpicture_fill ((avpicture *) PFrameYUV, out_buffer, pix_fmt_yuv422p, pcodecctx->width, pcodecctx->height);*/ ...... file *output=fopen ("Out.rgb", "wb+"); //------------------------------ while ( Av_read_frame (pformatctx, packet) >=0) {