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

Andy Furniss adf.lists at gmail.com
Mon Aug 19 00:21:47 CEST 2013


mokacao wrote:
> I'm doing a convert picture to MP4 video, the original image is PIX_FMT_BGRA
> format, now converted from RGB to YUV420P, I found many black spot around
> the picture, the follow is part of the core code, please help me to how to
> clear these black dots, or can tell me what information is missing, thank
> you.
>
> libffmpeg::SwsContext* swsContext = libffmpeg::sws_getContext( srcW, srcH,
> libffmpeg::PIX_FMT_BGRA,codecContext->width, codecContext->height,
> libffmpeg::PIX_FMT_YUV420P, SWS_BICUBIC, NULL, NULL, NULL);
>
> libffmpeg::sws_scale( swsContext , srcData, srcLinesize, 0, frame->Height,
> data->VideoFrame->data, data->VideoFrame->linesize );
>
> original png file
> <http://ffmpeg-users.933282.n4.nabble.com/file/n4660765/P0085.png>
>
> yuv420p image file(scale and clip)
> <http://ffmpeg-users.933282.n4.nabble.com/file/n4660765/yuv420p.png>

Well I don't know if you can do better with ffmpeg or not as I haven't 
tried and others may be able to suggest tweaks.

Referring  to the title of this post RGB -> 420 can't be lossless.

Chroma subsampling roughly works on "normal" video images, but if you 
push it with saturated graphics it can artifact.
Broadcasters will take this sort of thing into account when designing 
text overlays etc.

Below is just as some sort of explanation - I don't know if it's why in 
your particular case/commands used.

http://sas-origin.onstreammedia.com/origin/smpte0109/New%20Folder%201/Chan.pdf



More information about the ffmpeg-user mailing list