Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
As I know,convert pictures to bit stream by H264 or MPEG video need YUV frame,but I have bitmap only.How can I do it? Or there are some other ways?
Posted
Updated 8-Apr-13 4:09am
v2

1 solution

When you say you have a bitmap I guess you have an RGB or BGR bitmap?

To do a one off file conversion I would get a copy of IrfanView[^] . In fact I would get it anyway if you don't have it as it is the best tool I know for viewing not quite correctly formatted image data.

If you are trying to turn a series of bitmaps into H264 or some other form of MPEG video then RGB to YUV is the least of your problems. Encoding H264 is a deal more complicated than that. If you need to do this you should look into Microsoft Media Foundation for a very Windows/COM way to do that or into GStreamer for an open source Linux and Windows way to do it.
All the code you might ever need is somewhere in a GStreamer plugin but unfortunately it is also probably an undocumented mess written in C by a professor of hacking.

I have written the actual RGB to YUV code myself and it's not difficult to work out once you are certain about the relative sizes and ordering of the blocks of data and how the stride length is used ( Remember there are many YUV formats, YV12 and YUV422 being popular ones ). I can't post sample code sadly as I wrote it for a commercial client. I suggest you give it a try and post your code attempt if you get stuck.
 
Share this answer
 
Comments
nv3 8-Apr-13 18:10pm    
Great answer, Matthew.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900