[FFmpeg-user] How can I convert rbg to yuv420p loseless?

Bert Bruggeman b_bruggeman at ziggo.nl
Tue Aug 20 16:44:48 CEST 2013


if its not the alpha, it’s the subsampling used for yuv420
may be you could try yuv444p? that is 24 bits/pixel just as rgb-> kind of 
losless.

-----Original Message----- 
From: Andy Furniss
Sent: Tuesday, August 20, 2013 1:16 AM
To: FFmpeg user questions
Cc: bert1974
Subject: Re: [FFmpeg-user] How can I convert rbg to yuv420p loseless?

bert1974 wrote:
> PIX_FMT_BGRA contains alpha(=transparency) information.. to get the
> transparent edges right, you will have to blend/draw on a background color
> when converting from bgra to rgb. don't know how to do with SwsContext,
> maybe convert/blend rgba->rgb manual, than convert rgb to yuv using
> SwsContext
>
> (it looks like the image in your mail is blended on black instead of 
> white)

I don't think this is it as the alpha seems to be 255 everywhere on the
png and the artifacts seem to arise on conversion back to rgb.

Testing on 420 produced from the png with no sws options.

Converting back to rgb with ffmpeg -

ffmpeg -s 890x768 -pix_fmt yuv420p -i 420.yuv -sws_flags
+accurate_rnd+full_chroma_int -pix_fmt rgb24 420-ar-fc.rgb

is the best looking.

-sws_flags +accurate_rnd still has noticable "black" (really grey)
pixels but is better than no sws options or
-sws_flags +full_chroma_int which produces exactly the same output
(md5sum) as no sws options.



More information about the ffmpeg-user mailing list