Hi,
There is no function with the parameters you suggest.
You need first of all to set a SwsContext with desired parameters and then call
sws_scale as show in the example below.
Good luck.
________________
static AVFrame* RGBtoYUV(AVFrame *frame, AVCodecContext *c){
int ret;
AVFrame *frameYUV=av_frame_alloc();
assert(frameYUV);
frameYUV->format = c->pix_fmt;
frameYUV->width = c->width;
frameYUV->height = c->height;
int numBytes=avpicture_get_size(AV_PIX_FMT_YUV420P, c->width, c->height);
assert(numBytes);
uint8_t *dataBuffer = (uint8_t*) av_malloc (numBytes*sizeof(uint8_t));
frameYUV->data[0]=dataBuffer;
avpicture_fill((AVPicture *)frameYUV, dataBuffer, AV_PIX_FMT_YUV420P,
c->width, c->height);
struct SwsContext * YUVScaleCtx = sws_getContext
(
c->width,
c->height,
AV_PIX_FMT_RGB24,
c->width,
c->height,
AV_PIX_FMT_YUV420P,
SWS_BILINEAR,
0,
0,
0
);
ret = sws_scale(
YUVScaleCtx,
(const uint8_t *const *)frame->data,
frame->linesize, //stride is the size of a line + potential padding for
performance issue
0,
c->height,
frameYUV->data,
frameYUV->linesize
);
assert(ret);
return frameYUV;
}
Le 7 sept. 2015 à 10:31, qw <[email protected]> a écrit :
> Hi,
>
> There are too many ffmpeg functions. I want to find one function, which can
> convert one pixel format into another, and the argument is AVFrame. Does
> ffmpeg has this kind of function?
>
>
> Thanks!
>
> B.R.
>
> Andrew
>
>
>
> _______________________________________________
> Libav-user mailing list
> [email protected]
> http://ffmpeg.org/mailman/listinfo/libav-user
_______________________________________________
Libav-user mailing list
[email protected]
http://ffmpeg.org/mailman/listinfo/libav-user