ffmpeg復号フォーマット変換

654 ワード

フォーマット変換のキー操作を簡単に記録
int numBytes = avpicture_get_size(AV_PIX_FMT_RGB32, videoWidth, videoHeight);
uint8_t* out_buffer = (uint8_t *)av_malloc(numBytes * sizeof(uint8_t));
avpicture_fill(AVPicture *)pAVFrameRGB32, out_buffer, AV_PIX_RGB32, videoWidth, videoHeight);
pSwsContext = sws_getContext(videoWidth, videoHeight, AV_PIX_FMT_YUV420, videoWidth,
                    videoHeight, AV_PIX_FMT_RGB32, SWS_BICUBIC, NULL, NULL, NULL);


///      
sws_scale(pSwsContext, (const uint8_t *const *)tmp_frame->data, tmp_frame->linesize, 
                    0, videoHeight, pAVFrameRGB32->data, pAVFrameRGB32->linesize);