有没有可以快速将位图转换为YUV帧? [英] Is there any can convert a bitmap to YUV frame quickly?

查看:114
本文介绍了有没有可以快速将位图转换为YUV帧?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我所知,H264或MPEG视频将图片转换为比特流需要YUV帧,但我只有位图。我该怎么做?或者还有其他一些方法吗?

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?

推荐答案

当你说你有位图我想你有一个RGB或BGR位图?



要进行一次性文件转换,我会得到一份 IrfanView [ ^ ]。事实上,如果你没有它,我会得到它,因为它是我知道的最好的工具,用于查看格式不正确的图像数据。



如果你正在尝试将一系列位图转换为H264或其他形式的MPEG视频,然后将RGB转换为YUV是您遇到的最少问题。编码H264是一个比这更复杂的交易。如果你需要这样做,你应该考虑使用非常Windows / COM方式进行Microsoft Media Foundation或者使用开源Linux和Windows方式进入GStreamer。

所有代码你可能需要的是GStreamer插件中的某个地方但不幸的是它也可能是由黑客教授用C语言编写的无证文件。



我已经写了实际的RGB到YUV代码本身,一旦你确定数据块的相对大小和顺序以及如何使用步幅长度就不难解决(记住有很多YUV格式,YV12和YUV422是流行的) 。当我为商业客户写它时,我不能遗憾地发布示例代码。如果你遇到困难,我建议你试一试并发布你的代码尝试。
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.


这篇关于有没有可以快速将位图转换为YUV帧?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆