Opened 7 years ago

Closed 7 years ago

#5996 closed defect (needs_more_info)

Overlay output changes greatly if yuva420 instead of yuv420

Reported by: Misaki Owned by:
Priority: normal Component: avfilter
Version: git-master Keywords: overlay
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

I am using the most recent static git build. This particular bug has existed for a long time.

A white-on-black overlay that has an alpha channel or plane will be very bright even for very low alpha values, if the output from the overlay filter is yuva420. If the output is yuv420, then the output seems to be proportional to the degree of transparency.

How to replicate:

ffmpeg -hide_banner -filter_complex "color=black:d=1[b],color=white:d=1[w],color=white:2x2:d=1,geq=255/24*N:128,scale=20:20,scale=320:240,[w]alphamerge,[b]overlay,format=yuva420p,showinfo" -f null -

The scale then alphamerge is intended to allow variable transparency in a frame in a way that's faster than using the blend filter with expressions, and much faster than using the geq filter on a full-sized frame (unless there's been optimization in the past year).

In this case, yuva420p is the default output for the previous filters. If you change the output to an mp4 file, the default output will change to yuv420p since H.264 doesn't have an alpha channel. But putting yuva420p before the showinfo, and yuv420p after it, does result in the same problem.

The first few lines of output for showinfo:

[Parsed_showinfo_9 @ 0xa79dc0] n: 0 pts: 0 pts_time:0 pos: -1 fmt:yuva420p sar:1/1 s:320x240 i:P iskey:1 type:I checksum:02EDAAF8 plane_checksum:[35B2C10E 2BAB822B 2BAB822B 77F0E576] mean:[16 128 128 255] stdev:[0.0 0.0 0.0 0.0]
[null @ 0xa7f860] Encoder did not produce proper pts, making some up.
[Parsed_showinfo_9 @ 0xa79dc0] n: 1 pts: 1 pts_time:0.04 pos: -1 fmt:yuva420p sar:1/1 s:320x240 i:P iskey:1 type:I checksum:02EDAAF8 plane_checksum:[35B2C10E 2BAB822B 2BAB822B 77F0E576] mean:[16 128 128 255] stdev:[0.0 0.0 0.0 0.0]
[Parsed_showinfo_9 @ 0xa79dc0] n: 2 pts: 2 pts_time:0.08 pos: -1 fmt:yuva420p sar:1/1 s:320x240 i:P iskey:1 type:I checksum:AA52FF12 plane_checksum:[7F151537 2BAB822B 2BAB822B 77F0E576] mean:[76 128 128 255] stdev:[0.0 0.0 0.0 0.0]
[Parsed_showinfo_9 @ 0xa79dc0] n: 3 pts: 3 pts_time:0.12 pos: -1 fmt:yuva420p sar:1/1 s:320x240 i:P iskey:1 type:I checksum:247DA2F0 plane_checksum:[3B13B906 2BAB822B 2BAB822B 77F0E576] mean:[132 128 128 255] stdev:[0.0 0.0 0.0 0.0]
[Parsed_showinfo_9 @ 0xa79dc0] n: 4 pts: 4 pts_time:0.16 pos: -1 fmt:yuva420p sar:1/1 s:320x240 i:P iskey:1 type:I checksum:5A2A5139 plane_checksum:[89D4674F 2BAB822B 2BAB822B 77F0E576] mean:[165 128 128 255] stdev:[0.0 0.0 0.0 0.0]
[Parsed_showinfo_9 @ 0xa79dc0] n: 5 pts: 5 pts_time:0.2 pos: -1 fmt:yuva420p sar:1/1 s:320x240 i:P iskey:1 type:I checksum:A5FA6A74 plane_checksum:[8640808A 2BAB822B 2BAB822B 77F0E576] mean:[183 128 128 255] stdev:[0.0 0.0 0.0 0.0]
[Parsed_showinfo_9 @ 0xa79dc0] n: 6 pts: 6 pts_time:0.24 pos: -1 fmt:yuva420p sar:1/1 s:320x240 i:P iskey:1 type:I checksum:628E4F37 plane_checksum:[4B30654D 2BAB822B 2BAB822B 77F0E576] mean:[194 128 128 255] stdev:[0.0 0.0 0.0 0.0]

Luminance goes 16, 16 (since the color filter had mpeg range of 16~235 for luminance, and it was converted to full-range gray after the second scale so the 10 went to 0), then 76, 132, 165, 183, 194.

If you change the yuva420p to yuv420p, then . . . -v debug (or trace) doesn't actually show any changes because overlay filter doesn't report what its output is, but showinfo shows that the luminance has changed to 16, 16, 21, 31, 42, 53, 63, 74, . . .

If you switch the colours so white is on the bottom and black is on top with an alpha channel, then the outputs as yuva and yuv are almost, but in fact not exactly the same as each other. The last values for yuva420p output are . . . 99, 89, 78, 68, 57, 49, 38, 27, 18, 16, 16. For yuv420p output, it's . . . 103, 92, 81, 71, 60, 50, 39, 28, 18, 16, 16.

Other pixel formats may be bugged in different ways. The most significant effect I have seen is that the fade filter, when set to affect transparency, has this rather abrupt drop-off or onset of brightness from bright-over-dark. It might all be due to how the overlay filter works. If the intention was for the layers to combine 'non-linearly' due to gamma, then 'black over white' overlay should also be mostly bright, instead of having a steady progression.

Change History (5)

comment:1 by Elon Musk, 7 years ago

Are you sure this is not about premultiplied alpha that overlay filter do in this case?

comment:2 by Misaki, 7 years ago

It could be. I have no knowledge of how the overlay filter works.

comment:3 by Carl Eugen Hoyos, 7 years ago

Please provide the ffmpeg command line without the hide_banner option and the complete, uncut console output to make this a valid ticket.

comment:4 by Misaki, 7 years ago

ffmpeg -filter_complex "color=black:d=1[b],color=white:d=1[w],color=white:2x2:d=1,geq=255/24*N:128,scale=20:20,scale=320:240,[w]alphamerge,[b]overlay,format=yuva420p,showinfo" -f null -

ffmpeg version N-82759-g1f5630a-static http://johnvansickle.com/ffmpeg/ Copyright (c) 2000-2016 the FFmpeg developers

built with gcc 5.4.1 (Debian 5.4.1-4) 20161202
configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc-5 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gray --enable-libass --enable-libfreetype --enable-libfribidi --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libzimg
libavutil 55. 41.101 / 55. 41.101
libavcodec 57. 66.109 / 57. 66.109
libavformat 57. 58.101 / 57. 58.101
libavdevice 57. 2.100 / 57. 2.100
libavfilter 6. 68.100 / 6. 68.100
libswscale 4. 3.101 / 4. 3.101
libswresample 2. 4.100 / 2. 4.100
libpostproc 54. 2.100 / 54. 2.100

[Parsed_showinfo_9 @ 0x5636c80] config in time_base: 1/25, frame_rate: 25/1
[Parsed_showinfo_9 @ 0x5636c80] config out time_base: 0/0, frame_rate: 0/0
Output #0, null, to 'pipe:':

Metadata:

encoder : Lavf57.58.101
Stream #0:0: Video: wrapped_avframe, yuva420p, 320x240 [SAR 1:1 DAR 4:3], q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc (default)
Metadata:

encoder : Lavc57.66.109 wrapped_avframe

Stream mapping:

showinfo -> Stream #0:0 (wrapped_avframe)

Press [q] to stop, ? for help
[Parsed_showinfo_9 @ 0x5636c80] n: 0 pts: 0 pts_time:0 pos: -1 fmt:yuva420p sar:1/1 s:320x240 i:P iskey:1 type:I checksum:02EDAAF8 plane_checksum:[35B2C10E 2BAB822B 2BAB822B 77F0E576] mean:[16 128 128 255] stdev:[0.0 0.0 0.0 0.0]
[Parsed_showinfo_9 @ 0x5636c80] n: 1 pts: 1 pts_time:0.04 pos: -1 fmt:yuva420p sar:1/1 s:320x240 i:P iskey:1 type:I checksum:02EDAAF8 plane_checksum:[35B2C10E 2BAB822B 2BAB822B 77F0E576] mean:[16 128 128 255] stdev:[0.0 0.0 0.0 0.0]
[Parsed_showinfo_9 @ 0x5636c80] n: 2 pts: 2 pts_time:0.08 pos: -1 fmt:yuva420p sar:1/1 s:320x240 i:P iskey:1 type:I checksum:AA52FF12 plane_checksum:[7F151537 2BAB822B 2BAB822B 77F0E576] mean:[76 128 128 255] stdev:[0.0 0.0 0.0 0.0]
[Parsed_showinfo_9 @ 0x5636c80] n: 3 pts: 3 pts_time:0.12 pos: -1 fmt:yuva420p sar:1/1 s:320x240 i:P iskey:1 type:I checksum:247DA2F0 plane_checksum:[3B13B906 2BAB822B 2BAB822B 77F0E576] mean:[132 128 128 255] stdev:[0.0 0.0 0.0 0.0]
[Parsed_showinfo_9 @ 0x5636c80] n: 4 pts: 4 pts_time:0.16 pos: -1 fmt:yuva420p sar:1/1 s:320x240 i:P iskey:1 type:I checksum:5A2A5139 plane_checksum:[89D4674F 2BAB822B 2BAB822B 77F0E576] mean:[165 128 128 255] stdev:[0.0 0.0 0.0 0.0]
[Parsed_showinfo_9 @ 0x5636c80] n: 5 pts: 5 pts_time:0.2 pos: -1 fmt:yuva420p sar:1/1 s:320x240 i:P iskey:1 type:I checksum:A5FA6A74 plane_checksum:[8640808A 2BAB822B 2BAB822B 77F0E576] mean:[183 128 128 255] stdev:[0.0 0.0 0.0 0.0]
[Parsed_showinfo_9 @ 0x5636c80] n: 6 pts: 6 pts_time:0.24 pos: -1 fmt:yuva420p sar:1/1 s:320x240 i:P iskey:1 type:I checksum:628E4F37 plane_checksum:[4B30654D 2BAB822B 2BAB822B 77F0E576] mean:[194 128 128 255] stdev:[0.0 0.0 0.0 0.0]
[Parsed_showinfo_9 @ 0x5636c80] n: 7 pts: 7 pts_time:0.28 pos: -1 fmt:yuva420p sar:1/1 s:320x240 i:P iskey:1 type:I checksum:BD20AFBE plane_checksum:[6609C5D4 2BAB822B 2BAB822B 77F0E576] mean:[202 128 128 255] stdev:[0.0 0.0 0.0 0.0]
[Parsed_showinfo_9 @ 0x5636c80] n: 8 pts: 8 pts_time:0.32 pos: -1 fmt:yuva420p sar:1/1 s:320x240 i:P iskey:1 type:I checksum:8115B827 plane_checksum:[BA28CE3D 2BAB822B 2BAB822B 77F0E576] mean:[208 128 128 255] stdev:[0.0 0.0 0.0 0.0]
[Parsed_showinfo_9 @ 0x5636c80] n: 9 pts: 9 pts_time:0.36 pos: -1 fmt:yuva420p sar:1/1 s:320x240 i:P iskey:1 type:I checksum:79B49481 plane_checksum:[2AF9AA97 2BAB822B 2BAB822B 77F0E576] mean:[213 128 128 255] stdev:[0.0 0.0 0.0 0.0]
[Parsed_showinfo_9 @ 0x5636c80] n: 10 pts: 10 pts_time:0.4 pos: -1 fmt:yuva420p sar:1/1 s:320x240 i:P iskey:1 type:I checksum:A6FD44CC plane_checksum:[B85E5AE2 2BAB822B 2BAB822B 77F0E576] mean:[217 128 128 255] stdev:[0.0 0.0 0.0 0.0]
[Parsed_showinfo_9 @ 0x5636c80] n: 11 pts: 11 pts_time:0.44 pos: -1 fmt:yuva420p sar:1/1 s:320x240 i:P iskey:1 type:I checksum:08FFC8F9 plane_checksum:[6275DF0F 2BAB822B 2BAB822B 77F0E576] mean:[220 128 128 255] stdev:[0.0 0.0 0.0 0.0]
[Parsed_showinfo_9 @ 0x5636c80] n: 12 pts: 12 pts_time:0.48 pos: -1 fmt:yuva420p sar:1/1 s:320x240 i:P iskey:1 type:I checksum:9F9C2126 plane_checksum:[292F373C 2BAB822B 2BAB822B 77F0E576] mean:[222 128 128 255] stdev:[0.0 0.0 0.0 0.0]
[Parsed_showinfo_9 @ 0x5636c80] n: 13 pts: 13 pts_time:0.52 pos: -1 fmt:yuva420p sar:1/1 s:320x240 i:P iskey:1 type:I checksum:36487944 plane_checksum:[EFDA8F5A 2BAB822B 2BAB822B 77F0E576] mean:[224 128 128 255] stdev:[0.0 0.0 0.0 0.0]
[Parsed_showinfo_9 @ 0x5636c80] n: 14 pts: 14 pts_time:0.56 pos: -1 fmt:yuva420p sar:1/1 s:320x240 i:P iskey:1 type:I checksum:CCE5D162 plane_checksum:[B694E778 2BAB822B 2BAB822B 77F0E576] mean:[226 128 128 255] stdev:[0.0 0.0 0.0 0.0]
[Parsed_showinfo_9 @ 0x5636c80] n: 15 pts: 15 pts_time:0.6 pos: -1 fmt:yuva420p sar:1/1 s:320x240 i:P iskey:1 type:I checksum:983BFD71 plane_checksum:[99F11396 2BAB822B 2BAB822B 77F0E576] mean:[227 128 128 255] stdev:[0.0 0.0 0.0 0.0]
[Parsed_showinfo_9 @ 0x5636c80] n: 16 pts: 16 pts_time:0.64 pos: -1 fmt:yuva420p sar:1/1 s:320x240 i:P iskey:1 type:I checksum:2EE7559E plane_checksum:[60AB6BB4 2BAB822B 2BAB822B 77F0E576] mean:[229 128 128 255] stdev:[0.0 0.0 0.0 0.0]
[Parsed_showinfo_9 @ 0x5636c80] n: 17 pts: 17 pts_time:0.68 pos: -1 fmt:yuva420p sar:1/1 s:320x240 i:P iskey:1 type:I checksum:FA2E81AD plane_checksum:[440897C3 2BAB822B 2BAB822B 77F0E576] mean:[230 128 128 255] stdev:[0.0 0.0 0.0 0.0]
[Parsed_showinfo_9 @ 0x5636c80] n: 18 pts: 18 pts_time:0.72 pos: -1 fmt:yuva420p sar:1/1 s:320x240 i:P iskey:1 type:I checksum:90DAD9CB plane_checksum:[0AC2EFE1 2BAB822B 2BAB822B 77F0E576] mean:[232 128 128 255] stdev:[0.0 0.0 0.0 0.0]
[Parsed_showinfo_9 @ 0x5636c80] n: 19 pts: 19 pts_time:0.76 pos: -1 fmt:yuva420p sar:1/1 s:320x240 i:P iskey:1 type:I checksum:90DAD9CB plane_checksum:[0AC2EFE1 2BAB822B 2BAB822B 77F0E576] mean:[232 128 128 255] stdev:[0.0 0.0 0.0 0.0]
[Parsed_showinfo_9 @ 0x5636c80] n: 20 pts: 20 pts_time:0.8 pos: -1 fmt:yuva420p sar:1/1 s:320x240 i:P iskey:1 type:I checksum:5C3005E9 plane_checksum:[EE101BFF 2BAB822B 2BAB822B 77F0E576] mean:[233 128 128 255] stdev:[0.0 0.0 0.0 0.0]
[Parsed_showinfo_9 @ 0x5636c80] n: 21 pts: 21 pts_time:0.84 pos: -1 fmt:yuva420p sar:1/1 s:320x240 i:P iskey:1 type:I checksum:278631F8 plane_checksum:[D16D480E 2BAB822B 2BAB822B 77F0E576] mean:[234 128 128 255] stdev:[0.0 0.0 0.0 0.0]
[Parsed_showinfo_9 @ 0x5636c80] n: 22 pts: 22 pts_time:0.88 pos: -1 fmt:yuva420p sar:1/1 s:320x240 i:P iskey:1 type:I checksum:278631F8 plane_checksum:[D16D480E 2BAB822B 2BAB822B 77F0E576] mean:[234 128 128 255] stdev:[0.0 0.0 0.0 0.0]
[Parsed_showinfo_9 @ 0x5636c80] n: 23 pts: 23 pts_time:0.92 pos: -1 fmt:yuva420p sar:1/1 s:320x240 i:P iskey:1 type:I checksum:F2CD5E07 plane_checksum:[B4CA741D 2BAB822B 2BAB822B 77F0E576] mean:[235 128 128 255] stdev:[0.0 0.0 0.0 0.0]
[Parsed_showinfo_9 @ 0x5636c80] n: 24 pts: 24 pts_time:0.96 pos: -1 fmt:yuva420p sar:1/1 s:320x240 i:P iskey:1 type:I checksum:F2CD5E07 plane_checksum:[B4CA741D 2BAB822B 2BAB822B 77F0E576] mean:[235 128 128 255] stdev:[0.0 0.0 0.0 0.0]
frame= 25 fps=0.0 q=-0.0 Lsize=N/A time=00:00:01.00 bitrate=N/A speed=4.61x
video:12kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown

comment:5 by Elon Musk, 7 years ago

Resolution: needs_more_info
Status: newclosed

Not really clear what is buggy.

Note: See TracTickets for help on using tickets.