Log in

View Full Version : AVIF to APNG


jay123210599
2nd March 2025, 14:14
What can I use to convert animated AVIF files to APNGs without losing quality? Can ffmpeg do it? If so, how?

benwaggoner
4th March 2025, 02:12
What can I use to convert animated AVIF files to APNGs without losing quality? Can ffmpeg do it? If so, how?
APNG is a lossless RGB format while AVIF is an (almost always) lossy format typically in YUV. So there would be some format conversion loss. And for most content, you'd actually wind up increasing the file size, as PNG's native lossless compression doesn't work well with the sort of slight variations a frequency transform codec tends to introduce. PNG can be quite efficient for computer-rendered graphics ala PowerPoint or a desktop, but is ill suited for continuous tone content like a photograph.

I'd guess AVIF and APNG have similar compatibility profiles, so what's your scenario for wanting to do this conversion? You may well be better off just sticking with AVIF, or generating the APNG from original uncompressed sources if available.

GeoffreyA
4th March 2025, 14:17
What can I use to convert animated AVIF files to APNGs without losing quality? Can ffmpeg do it? If so, how?

Try something to this effect:

ffmpeg -i "INPUT.avif" -sws_flags accurate_rnd+full_chroma_int "OUTPUT.apng"

Z2697
4th March 2025, 17:47
The answer is already, literally just 1 scientific poking away, or actually already answered by our replies in his old trolling threads

Z2697
4th March 2025, 17:54
Actually here's a catch LOL.
As I have mentioned many times, animated HEIF is just like a normal video file, but with the first key frame referenced as "thumbnail image".
Now, for FFmpeg, when reading such HEIF it sees them as two video streams, the default stream selection will probably pick the wrong one.

GeoffreyA
5th March 2025, 06:21
Actually here's a catch LOL.
As I have mentioned many times, animated HEIF is just like a normal video file, but with the first key frame referenced as "thumbnail image".
Now, for FFmpeg, when reading HEIF it sees them as two video streams, the default stream selection will probably pick the wrong one.

Alas, there's always a glitch with FFmpeg!

Z2697
5th March 2025, 17:32
Alas, there's always a glitch with FFmpeg!

I'm OK to call it a feature, not a bug ;)

GeoffreyA
5th March 2025, 20:09
All right, with due deference to the FF of the MPEG, we'll call it a feature :)

benwaggoner
5th March 2025, 21:09
All right, with due deference to the FF of the MPEG, we'll call it a feature :)
Yeah, you can specify the stream you want to use in the command line.

FFmpeg can do anything, if you can figure out the syntax. But the syntax is not easy to figure out!

GeoffreyA
6th March 2025, 07:27
Yeah, you can specify the stream you want to use in the command line.

FFmpeg can do anything, if you can figure out the syntax. But the syntax is not easy to figure out!

When I discovered FFmpeg in 2018, I was astonished that it could do anything, quite a departure from the old way of using a range of tools to encode something. In the 2000s, I would use DVD Decrypter, DVD Audio Extractor, Azid, XMPEG, and VirtualDub to go from DVD to DivX-MP3 AVI. FFmpeg's syntax is like an obscure, miniature programming language at times, but when one finds something out, it's another weapon in one's toolkit.