Opened 11 years ago
Closed 9 years ago
#4443 closed defect (fixed)
Transparency gets lost when using palettegen / paletteuse
| Reported by: | Carl Eugen Hoyos | Owned by: | |
|---|---|---|---|
| Priority: | normal | Component: | avfilter |
| Version: | git-master | Keywords: | paletteuse alpha bounty |
| Cc: | rcopley@gmail.com | Blocked By: | |
| Blocking: | Reproduced by developer: | no | |
| Analyzed by developer: | no |
Description
When using palettegen / paletteuse to encode to pal8, transparency gets lost.
$ ffmpeg -i alpha.png -vf palettegen pal.png
ffmpeg version N-71320-gc4b2017 Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 4.7 (SUSE Linux)
configuration: --enable-gpl
libavutil 54. 22.100 / 54. 22.100
libavcodec 56. 34.100 / 56. 34.100
libavformat 56. 29.100 / 56. 29.100
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 13.101 / 5. 13.101
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 1.100 / 1. 1.100
libpostproc 53. 3.100 / 53. 3.100
Input #0, png_pipe, from 'alpha.png':
Duration: N/A, bitrate: N/A
Stream #0:0: Video: png, pal8, 21x21 [SAR 5:6 DAR 5:6], 25 tbr, 25 tbn, 25 tbc
Output #0, apng, to 'pal.png':
Metadata:
encoder : Lavf56.29.100
Stream #0:0: Video: apng, rgba, 16x16 [SAR 1:1 DAR 1:1], q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc
Metadata:
encoder : Lavc56.34.100 apng
Stream mapping:
Stream #0:0 -> #0:0 (png (native) -> apng (native))
Press [q] to stop, [?] for help
[Parsed_palettegen_0 @ 0x35ec900] 4(+1) colors generated out of 4 colors; ratio=1.000000
[apng @ 0x35f9040] Only a single frame so saving as a normal PNG.
frame= 1 fps=0.0 q=0.0 Lsize= 0kB time=00:00:00.04 bitrate= 24.2kbits/s
video:0kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 30.107527%
$ ffmpeg -i alpha.png -i pal.png -lavfi paletteuse out.gif
ffmpeg version N-71320-gc4b2017 Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 4.7 (SUSE Linux)
configuration: --enable-gpl
libavutil 54. 22.100 / 54. 22.100
libavcodec 56. 34.100 / 56. 34.100
libavformat 56. 29.100 / 56. 29.100
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 13.101 / 5. 13.101
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 1.100 / 1. 1.100
libpostproc 53. 3.100 / 53. 3.100
Input #0, png_pipe, from 'alpha.png':
Duration: N/A, bitrate: N/A
Stream #0:0: Video: png, pal8, 21x21 [SAR 5:6 DAR 5:6], 25 tbr, 25 tbn, 25 tbc
Input #1, png_pipe, from 'pal.png':
Duration: N/A, bitrate: N/A
Stream #1:0: Video: png, rgba, 16x16, 25 tbr, 25 tbn, 25 tbc
Output #0, gif, to 'out.gif':
Metadata:
encoder : Lavf56.29.100
Stream #0:0: Video: gif, pal8, 21x21 [SAR 5:6 DAR 5:6], q=2-31, 200 kb/s, 25 fps, 100 tbn, 25 tbc (default)
Metadata:
encoder : Lavc56.34.100 gif
Stream mapping:
Stream #0:0 (png) -> paletteuse:default
Stream #1:0 (png) -> paletteuse:palette
paletteuse -> Stream #0:0 (gif)
Press [q] to stop, [?] for help
frame= 1 fps=0.0 q=0.0 Lsize= 1kB time=00:00:00.04 bitrate= 185.0kbits/s
video:1kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Attachments (1)
Change History (10)
by , 11 years ago
comment:1 by , 11 years ago
| Cc: | added |
|---|
comment:2 by , 10 years ago
comment:3 by , 10 years ago
Consider offering a bounty. Developers are just volunteers and have limited time (and sometimes motivation, interest, etc). A bounty *may* help provide incentive if you are impatient.
And of course patches are always welcome from anyone.
comment:5 by , 9 years ago
| Keywords: | bounty added |
|---|
comment:6 by , 9 years ago
I'm going to look into this and see if I can submit a patch. I'm new to FFMPEG, so if anyone has any hints about what files to look at or anything that would be helpful.
comment:7 by , 9 years ago
You only have to look at paletteuse, afair, palettegen supports transparency.
comment:8 by , 9 years ago
I've got a fix for this that handles stills, but there's a bug in the gif codec that doesn't handle the resulting transparencies correctly when animating, so animated gifs coming out of this are not correct. I'm going to try to work on that this weekend.
@skavish: what are you looking for for the bounty?
comment:9 by , 9 years ago
| Component: | undetermined → avfilter |
|---|---|
| Keywords: | paletteuse added |
| Resolution: | → fixed |
| Status: | new → closed |
This ticket was fixed by Bjorn Roche in aba926e7d654b6dfab680130c92e571ee9a956f0 (and subsequent commits by Clément), I opened ticket #6813 for a gif encoding issue.



Would like to see this tackled. Other command line tools for image processing have been problematic for me.