- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
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
1 Solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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!
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!

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page