[FFmpeg-user] Unable to produce a yuv444p video that vlc will play back correctly

Peter Rabbitson rabbit+list at rabbit.us
Sun Nov 16 13:36:44 CET 2014


Hi!

This is not strictly a question on ffmpeg itself, as it may be the fault 
of vlc. But since vlc uses the same backend it is all somehow related.

I am trying to create a video which will display in full RGB color on a 
random player (in this case vlc). No matter what I do - I end up with 
color loss (likely yuv420 conversion) somewhere along the road. I have 
irrefutably verified that my video file contains the full color 
information, because I can do:

source image
   \
  video
     \
   extracted frame

and I end up arriving at the same source bytes (described in detail below).

However playback of the generated video and original/extracted images 
show a noticeable color loss when displayed side by side (screen capture 
in file side_by_side.png). What am I missing?

Thank you!

==== Follows description of the testing method

All (very small) files described below are attached to this message. The 
sequence of events:

I start with a small image:

> ~$ ffmpeg -hide_banner -i miniansi_orig.png
> Input #0, png_pipe, from 'miniansi_orig.png':
>   Duration: N/A, bitrate: N/A
>     Stream #0:0: Video: png, rgb24, 320x480 [SAR 1:1 DAR 2:3], 25 tbr, 25 tbn, 25 tbc
> At least one output file must be specified

I generate a short 1fps 10sec video from this source:

> ~$ ffmpeg -hide_banner -loop 1 -i miniansi_orig.png -t 10 -r 1 -c:v libx264 -crf 0 -preset veryslow -pix_fmt yuv444p miniansi.mkv
> Input #0, png_pipe, from 'miniansi_orig.png':
>   Duration: N/A, bitrate: N/A
>     Stream #0:0: Video: png, rgb24, 320x480 [SAR 1:1 DAR 2:3], 25 fps, 25 tbr, 25 tbn, 25 tbc
> [libx264 @ 0x1ce5000] using SAR=1/1
> [libx264 @ 0x1ce5000] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2
> [libx264 @ 0x1ce5000] profile High 4:4:4 Predictive, level 3.1, 4:4:4 8-bit
> [libx264 @ 0x1ce5000] 264 - core 142 r2431 a5831aa - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - http://www.videolan.org/x264.html - options: cabac=1 ref=16 deblock=1:0:0 analyse=0x3:0x133 me=umh subme=9 psy=0 mixed_ref=1 me_range=24 chroma_me=1 trellis=0 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=0 chroma_qp_offset=0 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=2 keyint=250 keyint_min=1 scenecut=40 intra_refresh=0 rc=cqp mbtree=0 qp=0
> Output #0, matroska, to 'miniansi.mkv':
>   Metadata:
>     encoder         : Lavf56.4.101
>     Stream #0:0: Video: h264 (libx264) (H264 / 0x34363248), yuv444p, 320x480 [SAR 1:1 DAR 2:3], q=-1--1, 1 fps, 1k tbn, 1 tbc
>     Metadata:
>       encoder         : Lavc56.1.100 libx264
> Stream mapping:
>   Stream #0:0 -> #0:0 (png (native) -> h264 (libx264))
> Press [q] to stop, [?] for help
> frame=   10 fps=0.0 q=-1.0 Lsize=      36kB time=00:00:10.00 bitrate=  29.1kbits/s dup=0 drop=228
> video:35kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 2.126225%
> [libx264 @ 0x1ce5000] frame I:1     Avg QP: 0.00  size: 34857
> [libx264 @ 0x1ce5000] frame P:9     Avg QP: 0.00  size:    24
> [libx264 @ 0x1ce5000] mb I  I16..4: 34.3%  5.5% 60.2%
> [libx264 @ 0x1ce5000] mb P  I16..4:  0.0%  0.0%  0.0%  P16..4:  0.0%  0.0%  0.0%  0.0%  0.0%    skip:100.0%
> [libx264 @ 0x1ce5000] 8x8 transform intra:5.5%
> [libx264 @ 0x1ce5000] coded y,u,v intra: 47.9% 47.8% 47.8% inter: 0.0% 0.0% 0.0%
> [libx264 @ 0x1ce5000] i16 v,h,dc,p: 68% 32%  0%  0%
> [libx264 @ 0x1ce5000] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 67% 23% 10%  0%  0%  0%  0%  0%  0%
> [libx264 @ 0x1ce5000] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 44% 46%  7%  1%  0%  0%  0%  0%  2%
> [libx264 @ 0x1ce5000] Weighted P-Frames: Y:0.0% UV:0.0%
> [libx264 @ 0x1ce5000] kb/s:28.06

I extract a single frame from the resulting video:

> ~$ ffmpeg -hide_banner -i miniansi.mkv -vframes 1 miniansi_frame.png
> [matroska,webm @ 0x24700a0] decoding for stream 0 failed
> Input #0, matroska,webm, from 'miniansi.mkv':
>   Metadata:
>     ENCODER         : Lavf56.4.101
>   Duration: 00:00:10.00, bitrate: 29 kb/s
>     Stream #0:0: Video: h264 (High 4:4:4 Predictive), yuv444p, 320x480 [SAR 1:1 DAR 2:3], 1 fps, 1 tbr, 1k tbn, 2 tbc (default)
>     Metadata:
>       ENCODER         : Lavc56.1.100 libx264
> Output #0, image2, to 'miniansi_frame.png':
>   Metadata:
>     encoder         : Lavf56.4.101
>     Stream #0:0: Video: png, rgb24, 320x480 [SAR 1:1 DAR 2:3], q=2-31, 200 kb/s, 1 fps, 1 tbn, 1 tbc (default)
>     Metadata:
>       encoder         : Lavc56.1.100 png
> Stream mapping:
>   Stream #0:0 -> #0:0 (h264 (native) -> png (native))
> Press [q] to stop, [?] for help
> frame=    1 fps=0.0 q=0.0 Lsize=N/A time=00:00:01.00 bitrate=N/A
> video:8kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown

This results (as expected) in a file identical to the source, proving 
that the video contains the full RGB (or equivalent yuv444) set of color 
information:

> ~$ diff miniansi_orig.png miniansi_frame.png; echo $?
> 0

Yet the results of playing the generated mkv in vlc (or for that matter 
any other player) are visibly terrible (see side_by_side.png)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: miniansi.mkv
Type: video/x-matroska
Size: 36360 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-user/attachments/20141116/4949c312/attachment.mkv>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: miniansi_frame.png
Type: image/png
Size: 7942 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-user/attachments/20141116/4949c312/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: miniansi_orig.png
Type: image/png
Size: 7942 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-user/attachments/20141116/4949c312/attachment-0001.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: side_by_side.png
Type: image/png
Size: 60713 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-user/attachments/20141116/4949c312/attachment-0002.png>


More information about the ffmpeg-user mailing list