开始研究视频编解码了

      在ffmpeg V0.61下,从视频中截图在网上找了很多种方法都不行,发现img_convert()找不到,最后在一个网站上搜到这段代码可以转换到rgb图像:

# img_convert()

img_convert ( (AVPicture  * )frameRGB, PIX_FMT_RGB24, (AVPicture * )frame, is -> video_st -> codec -> pix_fmt,  is -> video_st -> codec -> width,  is -> video_st -> codec -> height);


# sws_getContext(), sws_scale()

static   struct  SwsContext  * img_convert_ctx;
 img_convert_ctx 
=  sws_getContext ( is -> video_st -> codec -> width,
                          
is -> video_st -> codec -> height,  is -> video_st -> codec -> pix_fmt,
                          
is -> video_st -> codec -> width,  is -> video_st -> codec -> height,
                          PIX_FMT_RGB24, SWS_BICUBIC, NULL, NULL, NULL);
sws_scale (img_convert_ctx, frame
-> data, frame -> linesize, 0 is -> video_st -> codec -> height, frameRGB -> data, frameRGB -> linesize);

 

来源:http://www.cppblog.com/dragon/archive/2010/08/19/123993.html

你可能感兴趣的:(视频编解码)