Ticket #831 (closed defect: invalid)
gif: 1bpp with transparency decodes to black screen
| Reported by: | ami_stuff | Owned by: | |
|---|---|---|---|
| Priority: | normal | Component: | avcodec |
| Version: | git-master | Keywords: | bmp alpha |
| Cc: | Blocked By: | ||
| Blocking: | Reproduced by developer: | no | |
| Analyzed by developer: | no |
Description
C:\>ffmpeg -i 1bpp_transparent_white.gif out.bmp
ffmpeg version N-36088-gdd1fb65, Copyright (c) 2000-2011 the FFmpeg developers
built on Dec 22 2011 12:39:23 with gcc 4.6.2
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-ru
ntime-cpudetect --enable-avisynth --enable-bzlib --enable-frei0r --enable-libope
ncore-amrnb --enable-libopencore-amrwb --enable-libfreetype --enable-libgsm --en
able-libmp3lame --enable-libopenjpeg --enable-librtmp --enable-libschroedinger -
-enable-libspeex --enable-libtheora --enable-libvo-aacenc --enable-libvo-amrwben
c --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-
libxvid --enable-zlib
libavutil 51. 32.100 / 51. 32.100
libavcodec 53. 47.100 / 53. 47.100
libavformat 53. 28.100 / 53. 28.100
libavdevice 53. 4.100 / 53. 4.100
libavfilter 2. 53. 0 / 2. 53. 0
libswscale 2. 1.100 / 2. 1.100
libswresample 0. 5.100 / 0. 0.100
libpostproc 51. 2.100 / 51. 2.100
Input #0, image2, from '1bpp_transparent_white.gif':
Duration: 00:00:00.04, start: 0.000000, bitrate: N/A
Stream #0:0: Video: gif, pal8, 999x749, 25 tbr, 25 tbn, 25 tbc
[buffer @ 020F1340] w:999 h:749 pixfmt:pal8 tb:1/1000000 sar:0/1 sws_param:
Output #0, image2, to 'out.bmp':
Metadata:
encoder : Lavf53.28.100
Stream #0:0: Video: bmp, pal8, 999x749, q=2-31, 200 kb/s, 90k tbn, 25 tbc
Stream mapping:
Stream #0:0 -> #0:0 (gif -> bmp)
Press [q] to stop, [?] for help
frame= 1 fps= 0 q=0.0 Lsize= 0kB time=00:00:00.04 bitrate= 0.0kbits/
s
video:732kB audio:0kB global headers:0kB muxing overhead -100.000000%
Attachments
Change History
comment:1 Changed 17 months ago by cehoyos
- Keywords bmp alpha added
- Resolution set to invalid
- Status changed from new to closed
- Component changed from undetermined to avcodec
- Version changed from unspecified to git-master
The sample has a two-colour palette: Solid black and transparent black.
It is transcoded correctly with
ffmpeg -i 1bpp_transparent_white.gif out.png
ffmpeg -i 1bpp_transparent_white.gif -pix_fmt bgra out.png
ffmpeg -i 1bpp_transparent_white.gif -f image2 out.gif
I will attach a patch that allows to do the following:
ffmpeg -i 1bpp_transparent_white.gif out.bmp
ffmpeg -i out.bmp out.png
and get the same (semi-transparent) png as above.
But since neither ImageMagick? nor GIMP show out.bmp (with the patch) as semi-transparent, I am not sure if any application supports transparency in the bmp palette (and the Microsoft documentation repeatedly states the relevant value "must be zero" making a bug in FFmpeg's bmp palette reading code likely).
Otoh, it is possible that for ImageMagick? and GIMP, this depends on the BITMAPHEADER version, so please reopen if you find a palletized bmp that shows transparency with any application.
comment:2 follow-up: ↓ 3 Changed 17 months ago by beastd
Hi!
@cehoyos:
The patch is IMHO, as you already pointed yourself, not a good idea.
Some picky readers might not accept the files and if Microsoft ever decides to extend the format in
that place the FFmpeg generated files might be invalid or misinterpreted (rather unlikely but still).
Perhaps a new functionality that makes it possible for users to specify a background color
(or even picture) against which the transparent colors should be evaluated would be a good thing.
E.g. the user could choose white and would therefore end up in this example with the fully transparent
black palette entry translated to white (0x00000000 would be translated to 0x00FFFFFF in the palette).
edit: I mixed up opaque vs. fully transparent for the values in the example above.
@ami_stuff:
If you are interested, a new ticket with type enhancement could be opened so it isn't forgotten. Otherwise as I can't say how difficult it is to implement such a feature in current FFmpeg, I would say we just let it be for now.
comment:3 in reply to: ↑ 2 Changed 17 months ago by cehoyos
Replying to beastd:
The patch is IMHO, as you already pointed yourself, not a good idea.
Some picky readers might not accept the files and if Microsoft ever decides to extend the format in
that place the FFmpeg generated files might be invalid or misinterpreted (rather unlikely but still).
I believe we should produce such samples if ImageMagick?, GIMP or Photoshop read them with transparency, it is possible that this only needs another BITMAPHEADER version.



