Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

Domains: forum.doom9.org / forum.doom9.net / forum.doom9.se

 

Go Back   Doom9's Forum > Announcements and Chat > General Discussion

Reply
 
Thread Tools Search this Thread Display Modes
Old 6th January 2025, 07:31   #1  |  Link
jay123210599
Registered User
 
Join Date: Apr 2024
Posts: 504
From PNGs to APNGs

I have 227 PNGs. I want to make APNGs out of them where each APNG has 50 frames in them. I also want to make all of the APNGs in one setting. How do I do that using ffmpeg?

Last edited by jay123210599; 16th January 2025 at 16:40.
jay123210599 is offline   Reply With Quote
Old 6th January 2025, 09:02   #2  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 11,409
"From APNGs from PNGs",

Typo ?, Maybe "To APNGs from PNGs", or "From PNGs to APNGs".

Select EDIT, Advanced EDIT, on first post to edit thread title.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???
StainlessS is offline   Reply With Quote
Old 6th January 2025, 09:56   #3  |  Link
Balling
Registered User
 
Join Date: Feb 2020
Posts: 577
APNG implementaion in ffmpeg is subpar. You use https://apngasm.sourceforge.net/
Balling is offline   Reply With Quote
Old 6th January 2025, 10:00   #4  |  Link
GeoffreyA
Donor
 
Join Date: Jun 2024
Location: South Africa
Posts: 679
Here's a working method for the time being. I tried to do it all automatically, but nested FOR loops are problematic in Windows batch files. So, you will have to change the "start" and "end" variables each time. The first time would be "start=1" and "end=50" and the second time, "start=51" and "end=100" and so on. Your filenames will have to be in the format of "1.png" and so forth, starting from 1. Please run this on a copy of your original folder in case something gets accidentally overwritten. I'll see if I can improve to do everything automatically.

Code:
setlocal EnableDelayedExpansion

set start=1
set end=50

mkdir "OUT"

(for /l %%i in (!start!, 1, !end!) do @echo file %%i.png) > "Jay2025.txt"

ffmpeg -f concat -r 23.976 -i "Jay2025.txt" "OUT\FINAL_%RANDOM%.apng"

pause
GeoffreyA is offline   Reply With Quote
Old 6th January 2025, 10:03   #5  |  Link
GeoffreyA
Donor
 
Join Date: Jun 2024
Location: South Africa
Posts: 679
Quote:
Originally Posted by Balling View Post
APNG implementaion in ffmpeg is subpar. You use https://apngasm.sourceforge.net/
Seeing this now, Balling's solution would be the way to go and looks far simpler.
GeoffreyA is offline   Reply With Quote
Old 6th January 2025, 15:24   #6  |  Link
jay123210599
Registered User
 
Join Date: Apr 2024
Posts: 504
Quote:
Originally Posted by Balling View Post
APNG implementaion in ffmpeg is subpar. You use https://apngasm.sourceforge.net/
I don't want any delays between my frames.
jay123210599 is offline   Reply With Quote
Old 6th January 2025, 15:33   #7  |  Link
huhn
Registered User
 
Join Date: Oct 2012
Posts: 8,623
APNG without a delay makes no sense the delay is just a different word for FPS calculated differently.
huhn is offline   Reply With Quote
Old 6th January 2025, 16:21   #8  |  Link
GeoffreyA
Donor
 
Join Date: Jun 2024
Location: South Africa
Posts: 679
Quote:
Originally Posted by jay123210599 View Post
I don't want any delays between my frames.
As huhn points out, you can use a delay (0,041708375 should == 23.976 fps). Alternatively, my method works but requires editing the start and end variables.
GeoffreyA is offline   Reply With Quote
Old 6th January 2025, 20:07   #9  |  Link
jay123210599
Registered User
 
Join Date: Apr 2024
Posts: 504
Well, the default frame delay is 1/10 sec. How do I adjust it so my output APNG has 23.976 fps?

Also, which compressions for the tools are lossless, zlib, 7zip, or Zopfli? How does the number of iterations affect the compression/speed/quality? If I choose to optimize the palette and/or original color type of the PNGs, will it affect the quality of the APNG?
jay123210599 is offline   Reply With Quote
Old 6th January 2025, 20:12   #10  |  Link
Z2697
Registered User
 
Join Date: Aug 2024
Location: Between my two ears
Posts: 957
they are lossless
Z2697 is offline   Reply With Quote
Old 6th January 2025, 21:03   #11  |  Link
GeoffreyA
Donor
 
Join Date: Jun 2024
Location: South Africa
Posts: 679
Quote:
Originally Posted by jay123210599 View Post
Well, the default frame delay is 1/10 sec. How do I adjust it so my output APNG has 23.976 fps?

Also, which compressions for the tools are lossless, zlib, 7zip, or Zopfli? How does the number of iterations affect the compression/speed/quality? If I choose to optimize the palette and/or original color type of the PNGs, will it affect the quality of the APNG?
I'm not at the computer now to test it, but put in that value I posted, 0,041708375, and I reckon it should give 23.976 fps. As for the compression, try a few PNGs to convert to APNG, seeing which gives the better size; 7zip or Zopfli might have the edge. More iterations should yield better compression, but beyond some level, it will be diminishing returns.

Last edited by GeoffreyA; 6th January 2025 at 21:12.
GeoffreyA is offline   Reply With Quote
Old 6th January 2025, 21:30   #12  |  Link
Z2697
Registered User
 
Join Date: Aug 2024
Location: Between my two ears
Posts: 957
Shouldn't it be 1001/24000 = 0.0417833333333333333...?
Z2697 is offline   Reply With Quote
Old 6th January 2025, 21:39   #13  |  Link
GeoffreyA
Donor
 
Join Date: Jun 2024
Location: South Africa
Posts: 679
Quote:
Originally Posted by Z2697 View Post
Shouldn't it be 1001/24000 = 0.0417833333333333333...?
You are correct. I took the lazy option of dividing by 23.976.
GeoffreyA is offline   Reply With Quote
Old 7th January 2025, 16:07   #14  |  Link
jay123210599
Registered User
 
Join Date: Apr 2024
Posts: 504
Quote:
Originally Posted by GeoffreyA View Post
I'm not at the computer now to test it, but put in that value I posted, 0,041708375, and I reckon it should give 23.976 fps. As for the compression, try a few PNGs to convert to APNG, seeing which gives the better size; 7zip or Zopfli might have the edge. More iterations should yield better compression, but beyond some level, it will be diminishing returns.
What if I optimize the palette and/or original color type of the PNGs? Are you at your computer so you can test it now?
jay123210599 is offline   Reply With Quote
Old 7th January 2025, 17:14   #15  |  Link
Z2697
Registered User
 
Join Date: Aug 2024
Location: Between my two ears
Posts: 957
Why not test yourself?
You have no computer?
Z2697 is offline   Reply With Quote
Old 7th January 2025, 17:32   #16  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,669
Quote:
Originally Posted by jay123210599 View Post
What if I optimize the palette and/or original color type of the PNGs?
"optimize the palette" for PNG implies a lossy transform for most "video" scenarios - you decide which colors to discard . The more you discard, the more quality loss . The lossy transform is applied before the lossless PNG compression is applied

Palette optimization for PNG can be lossless if it's a very simple source with a few colors . This technique is typically used for simple graphics / logos with a few colors
poisondeathray is offline   Reply With Quote
Old 7th January 2025, 17:37   #17  |  Link
jay123210599
Registered User
 
Join Date: Apr 2024
Posts: 504
Quote:
Originally Posted by poisondeathray View Post
"optimize the palette" for PNG implies a lossy transform for most "video" scenarios - you decide which colors to discard . The more you discard, the more quality loss . The lossy transform is applied before the lossless PNG compression is applied

Palette optimization for PNG can be lossless if it's a very simple source with a few colors . This technique is typically used for simple graphics / logos with a few colors
My PNGs are all 24bit, and optimizing the palette will get rid of some colors?
jay123210599 is offline   Reply With Quote
Old 7th January 2025, 17:58   #18  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,669
Quote:
Originally Posted by jay123210599 View Post
My PNGs are all 24bit, and optimizing the palette will get rid of some colors?
In most "video" cases , yes .

In simple cases (e.g. simple logo with 6 colors) you might not get rid of any colors


You can test it yourself. If you cannot "see" the quality loss, measure it with an objective metric such as PSNR. This method was shown to you in other threads.

Another indirect way is to count the number of unique colors e.g. imagemagick. If you start with say 6,467,433 . But you optimize the pallette and now you have 1,234,453. You've lost millions of colors => quality loss

"mathematically lossless" means the decoded data is the same - or bit for bit identical
poisondeathray is offline   Reply With Quote
Old 7th January 2025, 18:25   #19  |  Link
GeoffreyA
Donor
 
Join Date: Jun 2024
Location: South Africa
Posts: 679
Quote:
Originally Posted by jay123210599 View Post
What if I optimize the palette and/or original color type of the PNGs? Are you at your computer so you can test it now?
Testing 24 PNGs made from your anime video, the size of the APNG was roughly the same regardless of the compression method. Zopfli was considerably slower, though, so use either zlib or 7zip, the former being a little bit faster. Increasing the number of iterations, at least for 7zip, made no real difference, so leave it at the default or use even 1, which is faster. Optimising the colour palette and type also made no difference in size, so turn it off, since, as poisondeathray notes, they may lead to loss of colour. As an anchor, FFmpeg created a much bigger file.

These are my findings; but you've got to test it out yourself because your files may yield different results.

Regarding the delay, use the ratio of 1001/24000. It yields 23.976 fps. Yesterday, I was under the impression that one could add a decimal number to the program, but actually, it has to be in the form of a fraction.
GeoffreyA is offline   Reply With Quote
Old 7th January 2025, 18:37   #20  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,669
My comments for "pallete optimization" for PNG were "in general" . It's a commonly used lossy technique for web graphics

If you're referring to apngasm specifically , the optimizations used there should be lossless according to the instructions.


Quote:
Some optimizations used in APNG Assembler might re-sort the
palette, or change the color type from RGBA and RGB modes
to RGB and indexed modes. Those optimizations are only performed
when they are lossless
, but if you want to avoid changing the
palette or colortype, use those switches to turn them off:

/kp : keep palette
/kc : keep color type
As usual, just read the instructions and/or test it yourself

Last edited by poisondeathray; 7th January 2025 at 18:41.
poisondeathray is offline   Reply With Quote
Reply

Tags
ffmpeg, png

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 17:25.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.