0

I recently finished the raytracing tutorial "Ray Tracing in One Weekend", which outputs to PPM. I'm trying to convert to PNG to share my results, but all the solutions I've tried have thrown errors.

When using FFMPEG with ffmpeg -i image.ppm out.png I get the following errors:

[image2 @ 0000020a3ef7a200] decoding for stream 0 failed
[image2 @ 0000020a3ef7a200] Could not find codec parameters for stream 0 (Video: ppm, none): unspecified size

Error while decoding stream #0:0: Invalid data found when processing input
Cannot determine format of input stream 0:0 after EOF
Error marking filters as finished

I tried adjusting the analyzeduration and probesize options to no effect.

When using ImageMagick with magick image.ppm out.png I get the following error:

magick: improper image header `image.ppm' @ error/pnm.c/ReadPNMImage/343.

(I've also tried online converters, but they all throw unhelpful errors as well.)

Most of the PPM viewers I've tried have no issue opening the input image, so corruption/bad data is unlikely. Edit: GIMP seems to have trouble opening it, and online viewers are 50/50. Image format is P3, are some programs only able to do P4-P6?

2
  • 1
    I can't reproduce the error with ffmpeg version N-90884-g19c3df0cd6 Copyright (c) 2000-2018 the FFmpeg developers Seems like the problem is with generated ppm file. You can try XNview MP, it can open (and convert) many image formats Commented May 22, 2022 at 18:01
  • 1
    @RomeoNinov took a closer look and the PPM was encoded in utf-16, switched to utf-8 and it worked perfectly. Thanks for the XNview suggestion though!
    – FiveTD
    Commented May 22, 2022 at 18:58

1 Answer 1

0

As revealed by OP file is kind of "corrupted" (at least not understandable by some of the software). OP change ppm from utf-16 encoding to utf-8. And case is resolved. Also you can use packages like XNview which support main desktop OS and also many graphic formats.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .