[FFmpeg-trac] #3409(undetermined:reopened): Impossible to transcode full range RGB videos with libx264, and keep full range + proper colors

FFmpeg trac at avcodec.org
Fri Jun 9 21:04:10 EEST 2017


#3409: Impossible to transcode full range RGB videos with libx264, and keep full
range + proper colors
-------------------------------------+-------------------------------------
             Reporter:  mzso         |                    Owner:
                 Type:  defect       |                   Status:  reopened
             Priority:  normal       |                Component:
              Version:  unspecified  |  undetermined
             Keywords:               |               Resolution:
             Blocking:               |               Blocked By:
Analyzed by developer:  0            |  Reproduced by developer:  0
-------------------------------------+-------------------------------------

Comment (by Djfe):

 This is still an issue.

 ffmpeg -i .\logo-huffyuv.avi -c:v libx264 -an test.mp4

 Is producing wrong colors.


 The following command does the right thing, but why isn't is the default?:
 ffmpeg -i .\logo-huffyuv.avi -pix_fmt yuv444p -vf
 scale=w=0:h=0:out_color_matrix=bt709 -x264opts
 colorprim=bt709:transfer=bt709:colormatrix=bt709 -c:v libx264 -an test.mp4

 -pix_fmt yuv444p can be considered optional since FFmpeg guesses that by
 itself.
 -x264opts colorprim=bt709:transfer=bt709:colormatrix=bt709 doesn't make
 the image look any different, but writes the correct colorspace
 information into the file, so that FFmpeg, Media Info and others can show
 it.


 Without the x264 opts bt709 wouldn't be written in the following ffprobe
 output:
 {{{
 Stream #0:0(und): Video: h264 (High 4:4:4 Predictive) (avc1 / 0x31637661),
 yuv444p(tv, bt709), 1920x1080, 12487 kb/s, 60 fps, 60 tbr, 500k tbn, 120
 tbc (default)
 }}}


 To me this looks like ffmpeg is converting to bt601 by default, but all
 players interpret it like bt709 or something like that. (But I could be
 wrong, in any way, the colors are converted wrong atm.)

 I extracted 6 frames from the original file (log-huffyuv.avi).
 You can find it here:
 https://drive.google.com/open?id=0B_dHhH1qeJ6DMU5ETG5rdFpDWGM
 (I wanted to upload to upload.ffmpeg.org, but the ftp server seems to be
 down)


 Output of the correct command on an avi file:
 {{{
 PS D:\some path> ffmpeg -i .\logo-huffyuv.avi -pix_fmt yuv444p -vf
 scale=w=0:h=0:out_color_matrix=bt709 -x264o
 pts colorprim=bt709:transfer=bt709:colormatrix=bt709 -c:v libx264 -crf 0
 -tune animation -preset placebo -profile:v high
 444 -an logo-H264-test.mp4
 ffmpeg version N-84814-gad7aff0 Copyright (c) 2000-2017 the FFmpeg
 developers
   built with gcc 6.3.0 (GCC)
   configuration: --enable-gpl --enable-version3 --enable-cuda --enable-
 cuvid --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-nvenc
 --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r
 --enable-gnutls --enable-iconv --enable-libass --enable-libbluray
 --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme
 --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame
 --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264
 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libsnappy
 --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame
 --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-
 libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-
 libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma
 --enable-zlib
   libavutil      55. 52.100 / 55. 52.100
   libavcodec     57. 86.103 / 57. 86.103
   libavformat    57. 68.100 / 57. 68.100
   libavdevice    57.  3.101 / 57.  3.101
   libavfilter     6. 78.101 /  6. 78.101
   libswscale      4.  3.101 /  4.  3.101
   libswresample   2.  4.100 /  2.  4.100
   libpostproc    54.  2.100 / 54.  2.100
 Input #0, avi, from '.\logo-huffyuv.avi':
   Metadata:
     encoder         : Lavf57.71.100
   Duration: 00:00:04.48, start: 0.000000, bitrate: 776213 kb/s
     Stream #0:0: Video: huffyuv (HFYU / 0x55594648), bgr0, 1920x1080,
 779087 kb/s, 60 fps, 60 tbr, 60 tbn, 60 tbc
 File 'logo-H264-test.mp4' already exists. Overwrite ? [y/N] y
 Stream mapping:
   Stream #0:0 -> #0:0 (huffyuv (native) -> h264 (libx264))
 Press [q] to stop, [?] for help
 [libx264 @ 0000000002037060] using cpu capabilities: MMX2 SSE2Fast SSSE3
 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
 [libx264 @ 0000000002037060] profile High 4:4:4 Predictive, level 5.1,
 4:4:4 8-bit
 [libx264 @ 0000000002037060] 264 - core 148 r2762 90a61ec - H.264/MPEG-4
 AVC codec - Copyleft 2003-2017 - http://www.videolan.org/x264.html -
 options: cabac=1 ref=16 deblock=1:1:1 analyse=0x1:0x131 me=esa 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=12
 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=25 scenecut=40 intra_refresh=0 rc=cqp mbtree=0 qp=0
 Output #0, mp4, to 'logo-H264-test.mp4':
   Metadata:
     encoder         : Lavf57.68.100
     Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv444p,
 1920x1080, q=-1--1, 60 fps, 500k tbn, 60 tbc
     Metadata:
       encoder         : Lavc57.86.103 libx264
     Side data:
       cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
 frame=  269 fps= 26 q=-1.0 Lsize=    5815kB time=00:00:04.46
 bitrate=10665.2kbits/s speed=0.437x
 video:5813kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB
 muxing overhead: 0.033330%
 [libx264 @ 0000000002037060] frame I:3     Avg QP: 0.00  size: 11825
 [libx264 @ 0000000002037060] frame P:266   Avg QP: 0.00  size: 22243
 [libx264 @ 0000000002037060] mb I  I16..4: 98.7%  0.0%  1.3%
 [libx264 @ 0000000002037060] mb P  I16..4:  1.6%  0.0%  0.3%  P16..4:
 4.4%  0.5%  0.5%  0.1%  0.1%    skip:92.5%
 [libx264 @ 0000000002037060] 8x8 transform intra:0.0% inter:11.9%
 [libx264 @ 0000000002037060] coded y,u,v intra: 22.1% 20.9% 20.3% inter:
 2.9% 2.7% 2.7%
 [libx264 @ 0000000002037060] i16 v,h,dc,p: 84% 14%  1%  1%
 [libx264 @ 0000000002037060] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 22% 18% 20%
 7% 11%  7%  9%  5%  1%
 [libx264 @ 0000000002037060] Weighted P-Frames: Y:13.2% UV:12.0%
 [libx264 @ 0000000002037060] ref P L0: 60.1%  0.5%  7.9%  5.0%  4.2%  4.1%
 3.6%  2.4%  2.0%  1.6%  1.8%  1.9%  1.6%  1.3%  1.2%  0.6%
 [libx264 @ 0000000002037060] kb/s:10621.08
 }}}

--
Ticket URL: <https://trac.ffmpeg.org/ticket/3409#comment:19>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list