3

I am downscaling 4K YUV420 video from the Panasonic LX100 to Full HD YUV444 using the ffmpeg console in Windows, and a script provided by user karl on the Personal View forum, modified for outputting H265 video at constant rate factor 18:

ffmpeg -i "input_path.MP4" -filter_complex "extractplanes=y+u+v[y][u][v]; [u] scale=w=3840:h=2160:flags=print_info+neighbor+bitexact [us]; [v] scale=w=3840:h=2160:flags=print_info+neighbor+bitexact [vs]; [y][us][vs]mergeplanes=0x001020:yuv444p,format=pix_fmts=yuv444p10le,scale=w=1920:h=1080:flags=print_info+bicubic+full_chroma_inp+full_chroma_int" -sws_dither none  -c:v libx265 -preset medium -crf 18 -c:a copy  -c:s copy -c:d copy  -map 0 "output_path.mp4"

The result, VLC tells me, is a 1080p yuv444 video, and I can see excellent color resolution, so far so good. However, the image has a slight red tint compared to the original.

What could cause that?

The full console output is:

ffmpeg -i "input.MP4" -filter_complex "extractplanes=y+u+v[y][u][v]; [u] scale=w=3840:h=2160:flags=print_info+neighbor+bitexact [us]; [v] scale=w=3840:h=2160:flags=print_info+neighbor+bitexact [vs]; [y
][us][vs]mergeplanes=0x001020:yuv444p,format=pix_fmts=yuv444p10le,scale=w=1920:h
=1080:flags=print_info+bicubic+full_chroma_inp+full_chroma_int" -sws_dither none
  -c:v libx265 -preset medium -crf 18 -c:a copy  -c:s copy -c:d copy  -map 0 "output.mp4"
ffmpeg version N-82080-g6969bed Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 5.4.0 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-dx
va2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-lib
ebur128 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --ena
ble-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfree
type --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enab
le-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-lib
openh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschr
oedinger --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheor
a --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvo
rbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --ena
ble-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --e
nable-decklink --enable-zlib
  libavutil      55. 32.100 / 55. 32.100
  libavcodec     57. 63.103 / 57. 63.103
  libavformat    57. 53.100 / 57. 53.100
  libavdevice    57.  0.103 / 57.  0.103
  libavfilter     6. 64.100 /  6. 64.100
  libswscale      4.  1.100 /  4.  1.100
  libswresample   2.  2.100 /  2.  2.100
  libpostproc    54.  0.100 / 54.  0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input.MP4':
  Metadata:
    major_brand     : mp42
    minor_version   : 1
    compatible_brands: mp42avc1
    creation_time   : 2015-06-27T21:42:33.000000Z
  Duration: 00:00:16.02, start: 0.000000, bitrate: 95327 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709)
, 3840x2160 [SAR 1:1 DAR 16:9], 95071 kb/s, 23.98 fps, 23.98 tbr, 360k tbn, 47.9
5 tbc (default)
    Metadata:
      creation_time   : 2015-06-27T21:42:33.000000Z
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, flt
p, 124 kb/s (default)
    Metadata:
      creation_time   : 2015-06-27T21:42:33.000000Z
File 'output.mp4' already exists. Overwrite ? [y/N] y
[swscaler @ 00000000041193c0] nearest neighbor / point scaler, from gray to gray
 using MMXEXT
[swscaler @ 0000000000556720] nearest neighbor / point scaler, from gray to gray
 using MMXEXT
[swscaler @ 000000000418cd60] bicubic scaler, from yuv444p10le to yuv444p using
MMXEXT
x265 [info]: HEVC encoder version 0.0
x265 [info]: build info [Windows][GCC 5.4.0][64 bit] 8bit
x265 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
x265 [info]: Main 4:4:4 profile, Level-4 (Main tier)
x265 [info]: Thread pool created using 4 threads
x265 [info]: Slices                              : 1
x265 [info]: frame threads / pool features       : 2 / wpp(17 rows)
x265 [info]: Coding QT: max CU size, min CU size : 64 / 8
x265 [info]: Residual QT: max TU size, max depth : 32 / 1 inter / 1 intra
x265 [info]: ME / range / subpel / merge         : hex / 57 / 2 / 2
x265 [info]: Keyframe min / max / scenecut       : 23 / 250 / 40
x265 [info]: Cb/Cr QP Offset                     : 6 / 6
x265 [info]: Lookahead / bframes / badapt        : 20 / 4 / 2
x265 [info]: b-pyramid / weightp / weightb       : 1 / 1 / 0
x265 [info]: References / ref-limit  cu / depth  : 3 / on / on
x265 [info]: AQ: mode / str / qg-size / cu-tree  : 1 / 1.0 / 32 / 1
x265 [info]: Rate Control / qCompress            : CRF-18.0 / 0.60
x265 [info]: tools: rd=3 psy-rd=2.00 rskip signhide tmvp strong-intra-smoothing
x265 [info]: tools: lslices=6 deblock sao
Output #0, mp4, to 'G:\darrask\Pics\2015.06 Goettingen\P1340763_karl3.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 1
    compatible_brands: mp42avc1
    encoder         : Lavf57.53.100
    Stream #0:0: Video: hevc (libx265) ([35][0][0][0] / 0x0023), yuv444p, 1920x1
080 [SAR 1:1 DAR 16:9], q=2-31, 23.98 fps, 24k tbn, 23.98 tbc (default)
    Metadata:
      encoder         : Lavc57.63.103 libx265
    Stream #0:1(und): Audio: aac (LC) ([64][0][0][0] / 0x0040), 48000 Hz, stereo, 124 kb/s (default)
    Metadata:
      creation_time   : 2015-06-27T21:42:33.000000Z
Stream mapping:
  Stream #0:0 (h264) -> extractplanes
  scale -> Stream #0:0 (libx265)
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[swscaler @ 00000000041b9da0] bicubic scaler, from yuv444p10le to yuv444p using MMXEXT
frame=    7 fps=0.0 q=0.0 size=       0kB time=00:00:00.00 bitrate=N/A speed=
frame=   17 fps= 16 q=0.0 size=       0kB time=00:00:00.49 bitrate=   0.7kbits/s
frame=   25 fps= 16 q=0.0 size=       0kB time=00:00:00.98 bitrate=   0.4kbits/s
frame=   29 fps= 14 q=-0.0 size=      61kB time=00:00:00.98 bitrate= 508.0kbits/
frame=   30 fps= 11 q=-0.0 size=      95kB time=00:00:00.98 bitrate= 795.6kbits/
frame=   31 fps=9.7 q=-0.0 size=     112kB time=00:00:01.00 bitrate= 918.1kbits/
...console output truncated by user...
frame=  377 fps=3.9 q=-0.0 size=    7017kB time=00:00:15.50 bitrate=3706.4kbits/
frame=  379 fps=3.9 q=-0.0 size=    7048kB time=00:00:15.53 bitrate=3717.4kbits/
frame=  383 fps=3.9 q=-0.0 size=    7131kB time=00:00:16.00 bitrate=3650.8kbits/
frame=  384 fps=3.7 q=-0.0 Lsize=    7561kB time=00:00:16.00 bitrate=3871.5kbits
/s speed=0.156x
video:7304kB audio:244kB subtitle:0kB other streams:0kB global headers:1kB muxin
g overhead: 0.169810%
x265 [info]: frame I:      2, Avg QP:18.71  kb/s: 16117.16
x265 [info]: frame P:     86, Avg QP:19.53  kb/s: 8568.68
x265 [info]: frame B:    296, Avg QP:23.40  kb/s: 2247.32
x265 [info]: Weighted P-Frames: Y:0.0% UV:0.0%
x265 [info]: consecutive B-frames: 2.3% 0.0% 9.1% 36.4% 52.3%

encoded 384 frames in 102.81s (3.73 fps), 3735.28 kb/s, Avg QP:22.51

output_path
>

Note it also has a red tint when I export to Prores with the original script by karl, and also when pix_fmts=yuv444p10le is not used (thus I presume 8 bits per pixel are used).

2
  • 2
    Show the full console output.
    – Gyan
    Commented Oct 23, 2016 at 4:22
  • Done and edited.
    – kdarras
    Commented Oct 24, 2016 at 8:41

2 Answers 2

3

I dug further and after reading the entire topic at Personal View, I found that user willyfan suggested to add in_range=full to both first scale arguments to correct a color shift that he also observed. And it works. So here is the full ffmpeg code, adapted from karl's script, for windows:

ffmpeg -i "input.MP4" -filter_complex "extractplanes=y+u+v[y][u][v]; [u] scale=w=3840:h=2160:in_range=full:flags=print_info+neighbor+bitexact [us]; [v] scale=w=3840:h=2160:in_range=full:flags=print_info+neighbor+bitexact [vs]; [y][us][vs]mergeplanes=0x001020:yuv444p,format=pix_fmts=yuv444p10le,scale=w=1920:h=1080:flags=print_info+bicubic+full_chroma_inp+full_chroma_int" -sws_dither none  -c:v libx265 -preset medium -crf 18 -c:a copy  -c:s copy -c:d copy  -map 0 "output.mp4"

So it seems that this is a good working script for converting 4K YUV420 footage to 1080p YUV444 footage with amazing results! My files are 5-10% the original size and have incredibly little quality loss.

PS: note that user karl says:

But if you use "in_rage=full:out_range=full", that should be fine with material recorded in the 0-255 value range. [...] You could try to use "in_range=full:out_range=mpeg" and see if that helps.

-1

huh? I would just use ffmpeg v4.x now and just use a command like ffmpeg -i "infile" -c:v libx265 -pix_fmt yuv444p -crf 18 "outfile"

1
  • this is not what is needed. We need to go from 4K YUK420 to 1080p YUV444 and this does not even downscale.
    – kdarras
    Commented Aug 26, 2018 at 19:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.