[FFmpeg-trac] #6203(avfilter:new): 'Color' filter does not always choose format correctly

FFmpeg trac at avcodec.org
Tue Feb 28 00:38:23 EET 2017


#6203: 'Color' filter does not always choose format correctly
----------------------------------+--------------------------------------
             Reporter:  Misaki    |                     Type:  defect
               Status:  new       |                 Priority:  normal
            Component:  avfilter  |                  Version:  git-master
             Keywords:            |               Blocked By:
             Blocking:            |  Reproduced by developer:  0
Analyzed by developer:  0         |
----------------------------------+--------------------------------------
 The 'color' filter produces frames of a specific color. This can include
 alpha channel with a color like "black at 0.5". However, if it is followed by
 a scale filter including scale2ref, the output format of 'color' filter is
 yuv420p, instead of yuva420p, so the alpha channel is lost.

 The context of this is creating a filter chain (for ffplay) that scales
 down the video and adds a shadow, then overlays it on a zoomed-in image.
 The shadow's base transparency was lost when adding in the new scale2ref
 filter.

 The above pretty much describes the issue, but here is the example made
 when I thought it was a bug with the new scale2ref filter:

 {{{
 misaki at dawn:~/software/ffmpeg$  ./ffmpeg -filter_complex
 color=black at 0.5:d=0.1,split,scale2ref[a][b],[b]nullsink,[a]showinfo,split,overlay
 -f null -
 ffmpeg version N-83585-ga5c1c7a8b3-static http://johnvansickle.com/ffmpeg/
 Copyright (c) 2000-2017 the FFmpeg developers
   built with gcc 5.4.1 (Debian 5.4.1-5) 20170205
   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. 47.100 / 55. 47.100
   libavcodec     57. 80.101 / 57. 80.101
   libavformat    57. 66.102 / 57. 66.102
   libavdevice    57.  2.100 / 57.  2.100
   libavfilter     6. 73.100 /  6. 73.100
   libswscale      4.  3.101 /  4.  3.101
   libswresample   2.  4.100 /  2.  4.100
   libpostproc    54.  2.100 / 54.  2.100
 [Parsed_showinfo_4 @ 0x3e8bac0] config in time_base: 1/25, frame_rate:
 25/1
 [Parsed_showinfo_4 @ 0x3e8bac0] config out time_base: 0/0, frame_rate: 0/0
 Output #0, null, to 'pipe:':
   Metadata:
     encoder         : Lavf57.66.102
     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.80.101 wrapped_avframe
 Stream mapping:
   overlay -> Stream #0:0 (wrapped_avframe)
 Press [q] to stop, [?] for help
 [Parsed_showinfo_4 @ 0x3e8bac0] 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_4 @ 0x3e8bac0] 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_4 @ 0x3e8bac0] n:   2 pts:      2 pts_time:0.08    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]
 frame=    3 fps=0.0 q=-0.0 Lsize=N/A time=00:00:00.12 bitrate=N/A
 speed=7.63x
 video:1kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB
 muxing overhead: unknown
 misaki at dawn:~/software/ffmpeg$  ./ffmpeg -filter_complex
 color=black at 0.5:d=0.1,showinfo,split,overlay -f null -
 ffmpeg version N-83585-ga5c1c7a8b3-static http://johnvansickle.com/ffmpeg/
 Copyright (c) 2000-2017 the FFmpeg developers
   built with gcc 5.4.1 (Debian 5.4.1-5) 20170205
   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. 47.100 / 55. 47.100
   libavcodec     57. 80.101 / 57. 80.101
   libavformat    57. 66.102 / 57. 66.102
   libavdevice    57.  2.100 / 57.  2.100
   libavfilter     6. 73.100 /  6. 73.100
   libswscale      4.  3.101 /  4.  3.101
   libswresample   2.  4.100 /  2.  4.100
   libpostproc    54.  2.100 / 54.  2.100
 [Parsed_showinfo_1 @ 0x4aaf2c0] config in time_base: 1/25, frame_rate:
 25/1
 [Parsed_showinfo_1 @ 0x4aaf2c0] config out time_base: 0/0, frame_rate: 0/0
 Output #0, null, to 'pipe:':
   Metadata:
     encoder         : Lavf57.66.102
     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.80.101 wrapped_avframe
 Stream mapping:
   overlay -> Stream #0:0 (wrapped_avframe)
 Press [q] to stop, [?] for help
 [Parsed_showinfo_1 @ 0x4aaf2c0] n:   0 pts:      0 pts_time:0       pos:
 -1 fmt:yuva420p sar:1/1 s:320x240 i:P iskey:1 type:I checksum:553FA22E
 plane_checksum:[35B2C10E 2BAB822B 2BAB822B CA42DCAC] mean:[16 128 128 127]
 stdev:[0.0 0.0 0.0 0.0]
 [Parsed_showinfo_1 @ 0x4aaf2c0] n:   1 pts:      1 pts_time:0.04    pos:
 -1 fmt:yuva420p sar:1/1 s:320x240 i:P iskey:1 type:I checksum:553FA22E
 plane_checksum:[35B2C10E 2BAB822B 2BAB822B CA42DCAC] mean:[16 128 128 127]
 stdev:[0.0 0.0 0.0 0.0]
 [Parsed_showinfo_1 @ 0x4aaf2c0] n:   2 pts:      2 pts_time:0.08    pos:
 -1 fmt:yuva420p sar:1/1 s:320x240 i:P iskey:1 type:I checksum:553FA22E
 plane_checksum:[35B2C10E 2BAB822B 2BAB822B CA42DCAC] mean:[16 128 128 127]
 stdev:[0.0 0.0 0.0 0.0]
 frame=    3 fps=0.0 q=-0.0 Lsize=N/A time=00:00:00.12 bitrate=N/A speed=
 9.2x
 video:1kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB
 muxing overhead: unknown
 }}}

 The 'split,overlay' is to retain the alpha channel, since otherwise it
 doesn't exist. In the first case, alpha is at 255 because it was dropped
 then re-added. In the second case, it is 127.

 Verbose output for the first case shows this:

 {{{
 [Parsed_color_0 @ 0x594e700] size:320x240 rate:25/1 duration:0.100000
 sar:1/1
 [Parsed_scale2ref_2 @ 0x594f6c0] w:iw h:ih flags:'bilinear' interl:0
 [Parsed_color_0 @ 0x5950ac0] size:320x240 rate:25/1 duration:0.100000
 sar:1/1
 [Parsed_scale2ref_2 @ 0x5951b00] w:iw h:ih flags:'bilinear' interl:0
 [Parsed_scale2ref_2 @ 0x5951b00] w:320 h:240 fmt:yuv420p sar:1/1 -> w:320
 h:240 fmt:yuva420p sar:1/1 flags:0x2
 }}}

 Which reveals that output from 'color' filter was yuv420p, though testing
 shows that the first resolution and format for the scale2ref filter is
 actually for the reference frame, not the frame that's modified.

 I note that this static build is actually a few weeks old I think but I
 don't think I could successfully build it myself from the source, so it's
 the most recent available to me.

 Not sure what keywords to add since the color filter has several names.

 (In this particular case, you can avoid the problem by adding a format
 filter between the 'color' and 'scale[2ref]' filters but many people won't
 realize they need to.)

--
Ticket URL: <https://trac.ffmpeg.org/ticket/6203>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list