Opened 11 years ago

Closed 11 years ago

#2158 closed defect (fixed)

Transparency gets lost on conversion from pal8 to yuva*

Reported by: Carl Eugen Hoyos Owned by:
Priority: normal Component: swscale
Version: git-master Keywords: alpha
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no

Description

http://thread.gmane.org/gmane.comp.video.ffmpeg.user/43291
I will attach a pal8 png sample that contains transparency, the overlay filter assumes an opaque image.

$ ffmpeg -i tests/lena.pnm -i pal8_alpha.png -filter_complex overlay out.png
ffmpeg version N-49026-g96d1b7f Copyright (c) 2000-2013 the FFmpeg developers
  built on Jan 19 2013 09:39:02 with gcc 4.7 (SUSE Linux)
  configuration: --enable-gpl --disable-indev=jack --enable-libx264
  libavutil      52. 15.100 / 52. 15.100
  libavcodec     54. 89.100 / 54. 89.100
  libavformat    54. 61.101 / 54. 61.101
  libavdevice    54.  3.102 / 54.  3.102
  libavfilter     3. 32.101 /  3. 32.101
  libswscale      2.  1.103 /  2.  1.103
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100
Input #0, image2, from 'tests/lena.pnm':
  Duration: 00:00:00.04, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: ppm, rgb24, 256x256, 25 tbr, 25 tbn, 25 tbc
Input #1, image2, from 'pal8_alpha.png':
  Duration: 00:00:00.04, start: 0.000000, bitrate: N/A
    Stream #1:0: Video: png, pal8, 174x98, 25 tbr, 25 tbn, 25 tbc
Output #0, image2, to 'out.png':
  Metadata:
    encoder         : Lavf54.61.101
    Stream #0:0: Video: png, rgba, 256x256, q=2-31, 200 kb/s, 90k tbn, 25 tbc
Stream mapping:
  Stream #0:0 (ppm) -> overlay:main
  Stream #1:0 (png) -> overlay:overlay
  overlay -> Stream #0:0 (png)
Press [q] to stop, [?] for help
frame=    1 fps=0.0 q=0.0 Lsize=N/A time=00:00:00.04 bitrate=N/A
video:134kB audio:0kB subtitle:0 global headers:0kB muxing overhead -100.016078%

The following works as expected:

$ ffmpeg -i pal8_alpha.png -pix_fmt rgba rgba_alpha.png
$ ffmpeg -i tests/lena.pnm -i rgba_alpha.png -filter_complex overlay out.png

Attachments (1)

pal8_alpha.png (4.4 KB ) - added by Carl Eugen Hoyos 11 years ago.

Download all attachments as: .zip

Change History (3)

by Carl Eugen Hoyos, 11 years ago

Attachment: pal8_alpha.png added

comment:1 by Carl Eugen Hoyos, 11 years ago

Component: avfilterswscale
Keywords: overlay removed
Status: newopen
Summary: overlay filter does not work with pal8 transparencyTransparency gets lost on conversion from pal8 to yuva*

I incorrectly assumed the overlay filter would accept pal8 as input, the real problem is that the transparency gets lost on conversion from pal8 to yuva*.

$ /ffmpeg -i pal8_alpha.png -pix_fmt yuva420p -vcodec ffv1 out.avi
ffmpeg version N-49257-g77b740a Copyright (c) 2000-2013 the FFmpeg developers
  built on Jan 25 2013 02:57:07 with gcc 4.7 (SUSE Linux)
  configuration: --enable-gpl --disable-indev=jack
  libavutil      52. 15.103 / 52. 15.103
  libavcodec     54. 90.100 / 54. 90.100
  libavformat    54. 61.104 / 54. 61.104
  libavdevice    54.  3.102 / 54.  3.102
  libavfilter     3. 33.100 /  3. 33.100
  libswscale      2.  2.100 /  2.  2.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100
Input #0, image2, from 'pal8_alpha.png':
  Duration: 00:00:00.04, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: png, pal8, 174x98, 25 tbr, 25 tbn, 25 tbc
[ffv1 @ 0x2c23f40] Storing alpha plane, this will require a recent FFV1 decoder to playback!
Output #0, avi, to 'out.avi':
  Metadata:
    ISFT            : Lavf54.61.104
    Stream #0:0: Video: ffv1 (FFV1 / 0x31564646), yuva420p, 174x98, q=2-31, 200 kb/s, 25 tbn, 25 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (png -> ffv1)
Press [q] to stop, [?] for help
frame=    1 fps=0.0 q=0.0 Lsize=      11kB time=00:00:00.04 bitrate=2195.6kbits/s
video:5kB audio:0kB subtitle:0 global headers:0kB muxing overhead 108.232170%

The output is opaque.

comment:2 by Michael Niedermayer, 11 years ago

Reproduced by developer: set
Resolution: fixed
Status: openclosed
Note: See TracTickets for help on using tickets.