Opened 19 months ago

Closed 19 months ago

Last modified 19 months ago

#9936 closed defect (duplicate)

Wrong color in FFplay

Reported by: Michael Koch Owned by:
Priority: normal Component: ffplay
Version: git-master Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Make two test videos which differ only in frame height:

ffmpeg -f lavfi -i color=0x20c010:s=400x576 -pix_fmt yuv420p -colorspace bt709 -color_trc bt709 -color_primaries bt709 -color_range pc -crf 0 -vcodec libx264 -t 5 -y out1.mp4

ffmpeg -f lavfi -i color=0x20c010:s=400x720 -pix_fmt yuv420p -colorspace bt709 -color_trc bt709 -color_primaries bt709 -color_range pc -crf 0 -vcodec libx264 -t 5 -y out2.mp4

When these videos are played in FFplay, the color is 42,183,29 in the first one and 32,161,24 in the second one.
The color should be identical if pixel format, colorspace, transfer characteristic, primaries and range are specified identically in the files.

I'm using "Just Color Picker" for measuring.
https://annystudio.com/software/colorpicker/

C:\Users\astro\Desktop\test>ffmpeg -f lavfi -i color=0x20c010:s=400x576 -pix_fmt yuv420p -colorspace bt709 -color_trc bt709 -color_primaries bt709 -color_range pc -crf 0 -vcodec libx264 -t 5 -y out1.mp4
ffmpeg version 2022-09-19-git-4ba68639ca-essentials_build-www.gyan.dev Copyright (c) 2000-2022 the FFmpeg developers

built with gcc 12.1.0 (Rev2, Built by MSYS2 project)
configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-zlib --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-sdl2 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-libfreetype --enable-libfribidi --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libgme --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libtheora --enable-libvo-amrwbenc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-librubberband
libavutil 57. 36.102 / 57. 36.102
libavcodec 59. 44.100 / 59. 44.100
libavformat 59. 32.100 / 59. 32.100
libavdevice 59. 8.101 / 59. 8.101
libavfilter 8. 49.100 / 8. 49.100
libswscale 6. 8.112 / 6. 8.112
libswresample 4. 9.100 / 4. 9.100
libpostproc 56. 7.100 / 56. 7.100

Input #0, lavfi, from 'color=0x20c010:s=400x576':

Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0:0: Video: wrapped_avframe, yuv420p, 400x576 [SAR 1:1 DAR 25:36], 25 fps, 25 tbr, 25 tbn

Stream mapping:

Stream #0:0 -> #0:0 (wrapped_avframe (native) -> h264 (libx264))

Press [q] to stop, ? for help
[libx264 @ 0000026908ad17c0] using SAR=1/1
[libx264 @ 0000026908ad17c0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0000026908ad17c0] profile High 4:4:4 Predictive, level 3.0, 4:2:0, 8-bit
[libx264 @ 0000026908ad17c0] 264 - core 164 r3098 7628a56 - H.264/MPEG-4 AVC codec - Copyleft 2003-2022 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=0 mixed_ref=1 me_range=16 chroma_me=1 trellis=0 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=0 chroma_qp_offset=0 threads=12 lookahead_threads=2 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 'out1.mp4':

Metadata:

encoder : Lavf59.32.100

Stream #0:0: Video: h264 (avc1 / 0x31637661), yuv420p(pc, bt709, progressive), 400x576 [SAR 1:1 DAR 25:36], q=2-31, 25 fps, 12800 tbn

Metadata:

encoder : Lavc59.44.100 libx264

Side data:

cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A

frame= 125 fps=0.0 q=-1.0 Lsize= 5kB time=00:00:04.96 bitrate= 8.4kbits/s speed= 32x
video:4kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 36.130718%
[libx264 @ 0000026908ad17c0] frame I:1 Avg QP: 0.00 size: 325
[libx264 @ 0000026908ad17c0] frame P:124 Avg QP: 0.00 size: 24
[libx264 @ 0000026908ad17c0] mb I I16..4: 99.9% 0.0% 0.1%
[libx264 @ 0000026908ad17c0] 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 @ 0000026908ad17c0] 8x8 transform intra:0.0%
[libx264 @ 0000026908ad17c0] coded y,uvDC,uvAC intra: 0.0% 0.1% 0.1% inter: 0.0% 0.0% 0.0%
[libx264 @ 0000026908ad17c0] i16 v,h,dc,p: 97% 0% 3% 0%
[libx264 @ 0000026908ad17c0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 0% 0% 100% 0% 0% 0% 0% 0% 0%
[libx264 @ 0000026908ad17c0] i8c dc,h,v,p: 100% 0% 0% 0%
[libx264 @ 0000026908ad17c0] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0000026908ad17c0] kb/s:5.27

Change History (3)

comment:1 by Michael Koch, 19 months ago

If a datascope filter is inserted in FFplay, then the hex values are identical in both videos and the color picker also reports identical colors:

ffplay -vf datascope=mode=color2 -autoexit %1

But without datascope filter the color picker still reports different colors:

ffplay -autoexit %1

Last edited 19 months ago by Michael Koch (previous) (diff)

comment:2 by Balling, 19 months ago

Resolution: duplicate
Status: newclosed

This is duplicate of #8862:
ffplay out1.mp4 -vf scale=in_color_matrix=auto,format=gbrp, color now is 32, 160, 23.

Next 0x20c010 is 32, 192, 16, so G is very different. Why? Cause you do not know what are you doing, by default the out color matrix from RGB is always limited BT.601 and thus you made two mistakes in one simple command, now (also removing deprecated vcodec):

ffmpeg -f lavfi -i color=0x20c010:s=400x576 -vf scale=out_color_matrix=bt709:out_range=pc -pix_fmt yuv420p -colorspace bt709 -color_trc bt709 -color_primaries bt709 -color_range pc -crf 0 -c:v libx264 -t 5 out1daws1.mp4

The color is 32, 192, 15, which 100% the same 32, 192, 16, yes in B component too, 16 cannot be preserved in 8 bit.

Last edited 19 months ago by Balling (previous) (diff)

comment:3 by Balling, 19 months ago

BTW, same happens on -vo gpu, but not -vo gpu-next in mpv.

Note: See TracTickets for help on using tickets.