Opened 4 years ago

Closed 22 months ago

#5622 closed defect (worksforme)

Image overlay with straight alpha

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


I have here png images with an alpha, rendered by Blackmagic Fusion. When I overly them on top of a video, I get dark boarders around the color.

ffmpeg command:

ffmpeg -i "video.mp4" -i straight_alpha0001.png -filter_complex "[0:v][1:v]overlay[out]" -map '[out]' -f opengl "test"

ffmpeg output:

ffmpeg version git-2016-04-27-a2ba50b Copyright (c) 2000-2016 the FFmpeg developers
  built with Apple LLVM version 7.3.0 (clang-703.0.29)
  configuration: --arch=x86_64 --prefix=/Users/jb_/dev/compileTools/local --disable-debug --disable-shared --disable-doc --enable-gpl --enable-version3 --enable-runtime-cpudetect --enable-avfilter --enable-fontconfig --enable-libfreetype --enable-libmp3lame --enable-opengl --enable-libvpx --enable-libx264 --enable-libx265 --enable-decklink --extra-cflags='-I$LOCALDESTDIR/include/decklink' --extra-ldflags='-L$LOCALDESTDIR/include/decklink' --extra-cflags=-DLIBTWOLAME_STATIC --extra-libs='-lxml2 -llzma -lstdc++ -lpng -lm -lexpat -liconv' pkg_config='pkg-config --static'
  libavutil      55. 22.101 / 55. 22.101
  libavcodec     57. 38.100 / 57. 38.100
  libavformat    57. 34.103 / 57. 34.103
  libavdevice    57.  0.101 / 57.  0.101
  libavfilter     6. 44.100 /  6. 44.100
  libswscale      4.  1.100 /  4.  1.100
  libswresample   2.  0.101 /  2.  0.101
  libpostproc    54.  0.100 / 54.  0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'video.mp4':
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isomiso2avc1mp41mp42
    encoder         : Lavf57.21.101
  Duration: 01:07:46.05, start: 0.000000, bitrate: 1789 kb/s
    Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 1024x576 [SAR 1:1 DAR 16:9], 1511 kb/s, 25 fps, 25 tbr, 12800 tbn (default)
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 192 kb/s (default)
      handler_name    : SoundHandler
    Stream #0:2(und): Data: none (rtp  / 0x20707472), 68 kb/s (default)
      creation_time   : 2016-02-26 14:01:33
      handler_name    : GPAC ISO Hint Handler
    Stream #0:3(und): Data: none (rtp  / 0x20707472), 11 kb/s (default)
      creation_time   : 2016-02-26 14:01:34
      handler_name    : GPAC ISO Hint Handler
Input #1, png_pipe, from '/Volumes/dev/scripts/shellScripts/snips/straight_alpha0004.png':
  Duration: N/A, bitrate: N/A
    Stream #1:0: Video: png, rgba(pc), 300x300, 25 tbr, 25 tbn
[opengl @ 0x7fab4c800000] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
[opengl outdev @ 0x7fab4c100160] SDL driver: 'Quartz'.
Output #0, opengl, to 'test':
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isomiso2avc1mp41mp42
    encoder         : Lavf57.34.103
    Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 1024x576 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 25 fps, 25 tbn (default)
      encoder         : Lavc57.38.100 rawvideo
Stream mapping:
  Stream #0:0 (h264) -> overlay:main
  Stream #1:0 (png) -> overlay:overlay
  overlay -> Stream #0:0 (rawvideo)
Press [q] to stop, [?] for help
frame=  396 fps= 60 q=-0.0 Lsize=N/A time=00:00:15.92 bitrate=N/A speed= 2.4x
video:342144kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown

Theoretical I could fix this with an expression like:

r/a, g/a, b/a, a

But I don't found any way to apply this.



Attachments (1)

straight_alpha0000.png (15.3 KB) - added by jb_alvarado 4 years ago.

Download all attachments as: .zip

Change History (4)

Changed 4 years ago by jb_alvarado

comment:1 Changed 4 years ago by jb_alvarado

I am not 100% sure if this is a straight alpha, but when I render this png's I have an option "Pre-Divide by Alpha", normally this option is off. If I turn it on, the overlay in ffmpeg is good, without boarder.
The Problem is, that I mostly don't know, if somebody turn this option on, or not. So it would be nice to have an option in ffmpeg to fix this.

comment:2 Changed 4 years ago by cehoyos

  • Keywords alpha added

comment:3 Changed 22 months ago by richardpl

  • Component changed from undetermined to avfilter
  • Resolution set to worksforme
  • Status changed from new to closed
  • Version changed from unspecified to git-master

Your png file is with premultiplied alpha. Overlay filter have now alpha option.
If I set alpha to premultiplied and format to rgb I get intended output.

Note: See TracTickets for help on using tickets.