Community
cancel
Showing results for 
Search instead for 
Did you mean: 
dashesy
Beginner
41 Views

UMC MPEG2Encoder with monochrome video

Jump to solution
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 Kudos

Accepted Solutions
Victor_C_Intel1
Employee
41 Views

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.

View solution in original post

3 Replies
dashesy
Beginner
41 Views
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.

Victor_C_Intel1
Employee
42 Views

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.

View solution in original post

dashesy
Beginner
41 Views
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!