Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.

UMC MPEG2Encoder with monochrome video

dashesy
初学者
727 次查看
Hi,

I can successfully encode 8bit monochrome video (UMC::GRAY) using H264Encoder using encParams.chroma_format_idc = 0;
encParams.info.color_format = UMC::GRAY;
The data is also sucessfully muxed to mp4 file format.

I also tried MPEG4Encoder and the video has wrong (has a pinkish look) chroma but the video is still there.

I want to know if it is possible to do the same using MPEG2Encoder, and how. If I feed the monochrome video to this encoder, the result is a completely pink video, so I guess I am missing a parameter to the encoder simillar to ones in H264EncoderParams

Particularly, is it true that all encoders only accept YUV12, YUV420 or GRAY format?

For the rest of the color formats (other than UMC::GRAY) I just use ColorSpaceConversion to convert to YUV420 before feeding it to the encoder, only for grayscale it is not implemented in the ColorSpaceConversion class and I have to rely on the encoder capbility to encode monochrome video, am I right?

Please let me know if I am correct, and BTW I think the input/output format of encoders, decoders, muxers, ... need more clarification in the document
0 项奖励
1 解答
Victor_C_Intel1
727 次查看

Hi,
The conversion is very simple. GRAY image you have is luminance (Y) component. To create U/V planes allocate, please,width*height/4 bytes per each plane and fill it with 128 (0x080) byte value. That's all.
These 3 planes compose a gray YUV420 image.

在原帖中查看解决方案

0 项奖励
3 回复数
dashesy
初学者
727 次查看
I further delved into the code and it seems MPEG2Encoder only supports YUV420, YUV422 and YUV444 formats and otherwise it assumes YUV420 for input which results in no UV chroma.

So I need to somehow convert from GRAY to YUV420 in order to encode monochrome using MPEG2Encoder, please correct me if I am wrong.
Is there a straightforward way to do this conversion?

Only H264Encoder accepts monochrome, so I ended up using RGB24 (although still black and white) to have all the encoders work properly.

0 项奖励
Victor_C_Intel1
728 次查看

Hi,
The conversion is very simple. GRAY image you have is luminance (Y) component. To create U/V planes allocate, please,width*height/4 bytes per each plane and fill it with 128 (0x080) byte value. That's all.
These 3 planes compose a gray YUV420 image.

0 项奖励
dashesy
初学者
727 次查看
Thanks! It could not be more straight forward.

Now I understand why it is not part of the ColorSpaceConversion, because the UV component does not really need to be filled with a constant each time!
0 项奖励
回复