我有一个使用 libavcodec (ffmpeg) 的项目。我正在使用它以 4:2:2 Profile, Main Level 对 MPEG-2 视频进行编码。我在 AVCodecContext 中选择了像素格式 PIX_FMT_YUV422P,但是我得到的视频输出的所有颜色都是错误的,在我看来,编码器错误地读取缓冲区,好像它认为它是 4:2:0 色度而不是比 4:2:2。这是我的编解码器设置:
//
// AVFormatContext* _avFormatContext previously defined as mpeg2video
//
//
// Set up the video stream for output
//
AVVideoStream* _avVideoStream = av_new_stream(_avFormatContext, 0);
if (!_avVideoStream)
{
err = ccErrWFFFmpegUnableToAllocateStream;
goto bail;
}
_avCodecContext = _avVideoStream->codec;
_avCodecContext->codec_id = CODEC_ID_MPEG2VIDEO;
_avCodecContext->codec_type = CODEC_TYPE_VIDEO;
//
// Set up required parameters
//
_avCodecContext->rc_max_rate = _avCodecContext->rc_min_rate = _avCodecContext->bit_rate = src->_avCodecContext->bit_rate;
_avCodecContext->flags = CODEC_FLAG_INTERLACED_DCT;
_avCodecContext->flags2 = CODEC_FLAG2_INTRA_VLC | …
Run Code Online (Sandbox Code Playgroud)