Opened 6 months ago

Closed 6 months ago

Last modified 6 months ago

#7819 closed enhancement (invalid)

It appears the overlay filter doesn't like odd numbers?.. (essentially the anointed yuv420 problem...)

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

Description

Build from: https://ffmpeg.zeranoe.com/builds/win64/static/ffmpeg-20190329-9dece05-win64-static.zip

C:\>ffmpeg -i "128x128.png" -i "64x64.png" -filter_complex overlay=1:1 "test.png"
ffmpeg version N-93482-g9dece050ef Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 8.2.1 (GCC) 20190212
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
  libavutil      56. 26.100 / 56. 26.100
  libavcodec     58. 47.106 / 58. 47.106
  libavformat    58. 26.101 / 58. 26.101
  libavdevice    58.  7.100 / 58.  7.100
  libavfilter     7. 48.100 /  7. 48.100
  libswscale      5.  4.100 /  5.  4.100
  libswresample   3.  4.100 /  3.  4.100
  libpostproc    55.  4.100 / 55.  4.100
Input #0, png_pipe, from 'C:\128x128.png':
  Duration: N/A, bitrate: N/A
    Stream #0:0: Video: png, rgb24(pc), 128x128 [SAR 2835:2835 DAR 1:1], 25 tbr, 25 tbn, 25 tbc
Input #1, png_pipe, from 'C:\64x64.png':
  Duration: N/A, bitrate: N/A
    Stream #1:0: Video: png, rgb24(pc), 64x64 [SAR 2835:2835 DAR 1:1], 25 tbr, 25 tbn, 25 tbc
Stream mapping:
  Stream #0:0 (png) -> overlay:main
  Stream #1:0 (png) -> overlay:overlay
  overlay -> Stream #0:0 (png)
Press [q] to stop, [?] for help
Output #0, image2, to 'test.png':
  Metadata:
    encoder         : Lavf58.26.101
    Stream #0:0: Video: png, rgba, 128x128 [SAR 1:1 DAR 1:1], q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc (default)
    Metadata:
      encoder         : Lavc58.47.106 png
frame=    1 fps=0.0 q=-0.0 Lsize=N/A time=00:00:00.04 bitrate=N/A speed=2.22x
video:0kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown

C:\>ffmpeg -hide_banner -i "128x128.png" -i "64x64.png" -filter_complex overlay=2:2 "test2.png"
Input #0, png_pipe, from 'C:\128x128.png':
  Duration: N/A, bitrate: N/A
    Stream #0:0: Video: png, rgb24(pc), 128x128 [SAR 2835:2835 DAR 1:1], 25 tbr, 25 tbn, 25 tbc
Input #1, png_pipe, from 'C:\64x64.png':
  Duration: N/A, bitrate: N/A
    Stream #1:0: Video: png, rgb24(pc), 64x64 [SAR 2835:2835 DAR 1:1], 25 tbr, 25 tbn, 25 tbc
Stream mapping:
  Stream #0:0 (png) -> overlay:main
  Stream #1:0 (png) -> overlay:overlay
  overlay -> Stream #0:0 (png)
Press [q] to stop, [?] for help
Output #0, image2, to 'test2.png':
  Metadata:
    encoder         : Lavf58.26.101
    Stream #0:0: Video: png, rgba, 128x128 [SAR 1:1 DAR 1:1], q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc (default)
    Metadata:
      encoder         : Lavc58.47.106 png
frame=    1 fps=0.0 q=-0.0 Lsize=N/A time=00:00:00.04 bitrate=N/A speed=2.35x
video:1kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown

The output of "overlay=1:1" is the same as "overlay=0:0". "overlay=2:2" works as expected.

Files attached.

Attachments (1)

overlay odd.7z (2.5 KB) - added by gdgsdg123 6 months ago.

Download all attachments as: .zip

Change History (4)

Changed 6 months ago by gdgsdg123

comment:1 follow-up: Changed 6 months ago by Gyan

  • Component changed from ffmpeg to avfilter
  • Keywords odd number removed
  • Priority changed from normal to minor
  • Resolution set to invalid
  • Status changed from new to closed

The overlay filter defaults to creating a yuv420p output frame so it will round down the x, y values so that they are even integers. To avoid this, add option format=auto or format=rgb e.g. -filter_complex overlay=1:1:format=rgb

comment:2 in reply to: ↑ 1 Changed 6 months ago by gdgsdg123

Replying to Gyan:

The overlay filter defaults to creating a yuv420p output frame so it will round down the x, y values so that they are even integers. To avoid this, add option format=auto or format=rgb e.g. -filter_complex overlay=1:1:format=rgb

Hmm...

Or tweak the overlay input source. (using a .png file of the same dimensions as the output, background transparent)

Warning: Doing so (without specifying format) may cause color shift...

Last edited 6 months ago by gdgsdg123 (previous) (diff)

comment:3 Changed 6 months ago by gdgsdg123

  • Summary changed from It appears the overlay filter doesn't like odd numbers?.. to It appears the overlay filter doesn't like odd numbers?.. (essentially the anointed yuv420 problem...)
  • Type changed from defect to enhancement
Note: See TracTickets for help on using tickets.