Opened 3 years ago

Last modified 3 years ago

#6381 new defect

Re-encoding png image fails

Reported by: guest123 Owned by:
Priority: normal Component: avcodec
Version: git-master Keywords: png
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no


Summary of the bug: Sometimes Ffmpeg fails to re-encode png file which is correct according to the png file formet specification.

How to reproduce: Try to re-encode this file (it is a valid png file):

ffmpeg -i 1.hex -y 2.png

Output of Ffmpeg is

[png @ 0000000000574520] inflate returned error -3
Input #0, png_pipe, from '1.hex':
  Duration: N/A, bitrate: N/A
    Stream #0:0: Video: png, rgb24(pc), 2400x1500 [SAR 3779:3779 DAR 8:5], 25 tbr, 25 tbn, 25 tbc
Output #0, image2, to '1.png':
    encoder         : Lavf57.57.100
    Stream #0:0: Video: png, rgb24, 2400x1500 [SAR 3779:3779 DAR 8:5], q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc
      encoder         : Lavc57.66.101 png
Stream mapping:
  Stream #0:0 -> #0:0 (png (native) -> png (native))
Press [q] to stop, [?] for help
[png @ 00000000005658e0] inflate returned error -3
Error while decoding stream #0:0: Generic error in an external library
frame=    0 fps=0.0 q=0.0 Lsize=N/A time=00:00:00.00 bitrate=N/A speed=   0x    
video:0kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Output file is empty, nothing was encoded (check -ss / -t / -frames parameters if used)
Conversion failed!

All other png encoders/decoders can process this file correctly. This is how the image should look like:

Change History (2)

comment:1 in reply to: ↑ description Changed 3 years ago by cehoyos

  • Component changed from ffmpeg to avcodec

Replying to guest123:

All other png encoders/decoders can process this file correctly.

Which did you test? At least libpng fails here.
Why do you believe this is a valid png file?

comment:2 Changed 3 years ago by guest123

Which did you test? I tested it with a lot of image viewers/editors on windows. All modern browsers can display that image (Chrome, Mozilla, Safari, Opera, IE, etc), you can edit it in Paint, open and edit it with ACDSee Image Viewer, Mirilic Action Image Viewer, Panorama Maker, Image Resizer etc. All of them opens image without anywarnings or errors.

Why do you believe this is a valid png file? Actually, this is not completely valid png file. One of IDAT chunks has unconsistent CRC32 hash, which means that the file may be corrupted. But, I tested some images with bad CRC32 hashes and Ffmpeg converts them without errors. Also, in this image IEND chunk is missing, and also a few IDAT chunks at the ends. Shouldn't Ffmpeg just fill that part of image with transparent or black pixel data (like all other image editors do)?

Note: See TracTickets for help on using tickets.