Hi,
VB 6.0 is dead. And if you want to use them in your VS 2008/2010 Environment then you
cannot use
(The same is also mentioned in Dranger's Tutorials.)
if(frameFinished) {
img_convert((AVPicture *)pFrameRGB, PIX_FMT_RGB24,
(AVPicture*)pFrame, pCodecCtx->pix_fmt, pCodecCtx->width,
pCodecCtx->height);
img_convert() is deprecated method since FFMPEG 0.5.* builds.
However there is an alternative to it. FFMPEG package comes with a SWScale library. To use swscalar you have to configure your compilation with
./configure --enable-gpl --enable-swscaler ...
.
About SWScale:
Swscale is mainly used for players, not encoding/decoding. It's necessary if you want to display the video at a different pixel size/aspect ratio than it was encoded at and you don't have hardware video scaling support. Swscale also performs colorspace conversion between various RGB and YUV color formats, and conversion between packed (all channels in a single buffer) and planar (each channel has its own buffer) formats. All of these routines are highly optimized; as far as I know, no faster software implementation presently exists for any of them, at least on x86 and x86_64.
Swscale also may be needed for encoding video, if the source video is not already in the format needed by the encoder. For instance, if your source video is RGB, you'll probably need to convert it to the appropriate YUV planar format, since most codecs work on YUV. This entails both colorspace conversion (an affine transformation of the R,G,B vectors) and actual scaling (resampling), since most YUV formats use half-resolution U and V planes (color planes) compared to the Y plane (luma, i.e. intensity data). Also the SWScaler library is accelerated by MMX instructions.
What is lib Swscale used for by ffmpeg programers?[
^]
Here's a sample implementation:
struct SwsContext *img_convert_ctx = NULL;
AVFormatContext *pFormatCtx = ...;
AVFrame pFrame = ... ;
AVPicture pict = ...;
if(img_convert_ctx == NULL)
{
...
img_convert_ctx = sws_getContext(width,height, pFormatCtx->streams[...]->codec->pix_fmt , w, h, PIX_FMT_YUV420P, SWS_BICUBIC, NULL, NULL, NULL);
if(img_convert_ctx == NULL)
{
fprintf(stderr, "ERROR- %s\n", SDL_GetError());
exit(1);
}
}
sws_scale(img_convert_ctx, pFrame->data, pFrame->linesize, 0, is->pFormatCtx->streams[is->videoStream]->codec->height, pict.data,pict.linesize);
You must have proper context to do all these operations. Rest is fine.