Converting YUV420SP to YUV420P

怎甘沉沦 提交于 2019-11-29 23:54:27

问题


How do I to convert YUV420SP to YUV420P using ffmpeg sws_scale or another efficient method?


回答1:


There are an enormous amount of different YUV-formats available, as a starting point see http://www.fourcc.org/yuv.php

You need to be more specific in you question since "Semi Planar" and "Planar" doesn't really tell how the data is formatted.

But as a general advice, it's just raw-data placed contiguously. All you need to do is to read the correct amount of data from the in-stream and write it to the out-stream using your favorite language.




回答2:


If you are using swscale lib from ffmpeg the following code may help you.

static struct SwsContext *swsContext;

swsContext = sws_getContext(c->width, c->height,PIX_FMT_NV21,
        c->width, c->height,
        PIX_FMT_YUV420P,
        SWS_FAST_BILINEAR, NULL, NULL, NULL);

avpicture_fill((AVPicture*)picture, data, PIX_FMT_NV21, c->width, c->height);

avpicture_fill((AVPicture*)outpic, outbuffer, PIX_FMT_YUV420P, c->width, c->height);

sws_scale(swsContext, picture->data, picture->linesize, 0, c->height, outpic->data, outpic->linesize);

sws_freeContext(swsContext);


来源:https://stackoverflow.com/questions/6094738/converting-yuv420sp-to-yuv420p

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!