xufuji456 / FFmpegAndroid

FFmpeg实现视频裁剪、水印、转码、编解码、转Gif动图;FFmpeg本地推流、H264与RTMP实时推流直播;OpenGL滤镜特效,视频拍摄。音视频学习路线,音视频知识总结、流媒体协议
5.1k stars 1.27k forks source link

The data I obtained is in AV_PIX_FMT_YUVJ422P format, how to convert it to YUV? #238

Closed hzhh110 closed 1 year ago

hzhh110 commented 1 year ago

The data I obtained is in AV_PIX_FMT_YUVJ422P format, how to convert it to YUV?

static void YUV420PPackages(uint8_t yuv420, uint8_t y_ptr, uint8_t u_ptr, uint8_t v_ptr, int width, int height) { int yLen = width height; int uvLen = width / 2 height / 2; memcpy((unsigned char )yuv420, y_ptr, yLen); memcpy((unsigned char )yuv420 + yLen, u_ptr, uvLen); memcpy((unsigned char *)yuv420+yLen+uvLen, v_ptr, uvLen); } YUV420PPackages(buf, pVideoFrame->data[0], pVideoFrame->data[1], pVideoFrame->data[2], pCodecCtx->width, pCodecCtx->height);

xufuji456 commented 1 year ago

Use swscale to convert colorspace, from YUVJ422P to YUV420P, or anything else