[FFmpeg-devel] YUV image conversion

Tomas Härdin tomas.hardin
Sat Mar 5 14:37:24 CET 2011

jelliott at rohan.sdsu.edu skrev 2011-03-04 22:46:
>> Hi,
>> On Thu, Mar 3, 2011 at 7:52 PM,<jelliott at rohan.sdsu.edu>  wrote:
>>> My problem is that when the U and V components are zero'd out, I obtain
>>> a
>>> green image when I am expecting a black and white image.  On the other
>>> end
>>> of the spectrum, when I set the U and V components to 255, I obtain a
>>> dark
>>> magenta image.  A black and white image can only be obtained if the U
>>> and
>>> V components are set to their midrange values of 217.  I have attached
>>> copies of sample images to illustrate this.
>>> I have found out, through emailing one of the authors of ffmpeg, that
>>> the
>>> U and V components have an offset of 128 in order to represent negative
>>> values.  I need to find out where in ffmpeg this offset is taking place.
>>> I only want to stream the Y data without having to transmit values for
>>> the
>>> U and V data.  I want to be able to set those values to 0 initially and
>>> only transmit the Y data.  If someone could point me in the right
>>> direction as to how to do this or just point me to where the UV offset
>>> is
>>> coded, I would greatly appreciate it.
>> Your solution is likely to transmit Y-data only and read it as
>> PIX_FMT_GRAY (which is basically Y-only, like Y800) to
>> PIX_FMT_YUV420P, that will do approximately the right thing.
> How can the user specify the format they want the image read into?  Can
> you just specify PIX_FMT_GRAY in the command line?

Assuming you mean the ffmpeg CLI, you can do something like:

ffmpeg -f rawimage -s 720x576 -pix_fmt gray -i input.foo  etc.


More information about the ffmpeg-devel mailing list