Almost no file size decrease by png compression level
Hello,
comparing
source image original file size = 89298
ntsc-rs-cli --input image_source/nanda_PAL.jpg --output NANDA-0.png -p nanda_initial.json --single-frame-time 1 -c png --compression-level 0
with
ntsc-rs-cli --input image_source/nanda_PAL.jpg --output NANDA-9.png -p nanda_initial.json --single-frame-time 1 -c png --compression-level 9
results in a file size ratio of
> 3989646/3340887
[1] 1.194188
of compression 0 vs. 9 which is not that much. Saving a frame from GUI results in a much smaller file size.
How small is the equivalent frame if you save it from the GUI?
Good point, my mistake, there is no difference to the GUI, but using some external png converter (xnview) with compression 9 (input png, output png) it results in 599397 using the output of ntsc-rs as input - which is
> 3989646/599397
[1] 6.656099
So the switch in the GUI button save frame does not result in the possible file size reduction while creating png compared to what's probably possible.
btw - png compression is lossless?
I'm trying this on my own machine, and the output size for a sample frame is ~800KB. Compressing it with oxipng -o max gives 500KB. How are you getting 4MB files? What's your output resolution?
Is it possible that the encoder is somehow outputting 16-bit PNGs instead of 8-bit ones? This shouldn't be happening, but there might be some more Debian-specific codec weirdness.
btw - png compression is lossless?
Yes
this was create by the 0.9.2 standalone gui version:
$ mediainfo nanda_initial_orig.png
General
Complete name : nanda_initial_orig.png
Format : PNG
Format/Info : Portable Network Graphic
File size : 2.23 MiB
Image
Format : PNG
Format/Info : Portable Network Graphic
Compression : Deflate
Width : 640 pixels
Height : 480 pixels
Color space : RGB
Bit depth : 8 bits
Compression mode : Lossless
Stream size : 2.23 MiB (100%)
the input was
$ mediainfo image_source/nanda_PAL.jpg
General
Complete name : image_source/nanda_PAL.jpg
Format : JPEG
File size : 87.2 KiB
Image
Format : JPEG
Width : 768 pixels
Height : 576 pixels
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Compression mode : Lossy
Stream size : 87.2 KiB (100%)
...just repeated it with the GUI, same result.
Can you upload the original image and settings preset so I can try to replicate this? (EDIT: hang on, now it's 2 MB and not 4?)
sure
https://raw.githubusercontent.com/abcnorio/aas-mult/refs/heads/main/image_source/nanda_PAL.jpg
and profile
https://raw.githubusercontent.com/abcnorio/aas-mult/refs/heads/main/nanda_initial.json
the cli version created calls (see start of this thread for copy&paste) resulted indeed in
-rw-r--r-- 1 xxx xxx 3989646 9. Apr 10:18 NANDA-0.png
-rw-r--r-- 1 xxx xxx 3340887 9. Apr 10:19 NANDA-9.png
compared to GUI
2336198
but this diff seems to be due to resolution - the cli version does not change the resolution (?) which is nothing to complain about. The diff correlates with resolution.
$ mediainfo NANDA-0.png
General
Complete name : NANDA-0.png
Format : PNG
Format/Info : Portable Network Graphic
File size : 3.80 MiB
Image
Format : PNG
Format/Info : Portable Network Graphic
Compression : Deflate
Width : 768 pixels
Height : 576 pixels
Color space : RGB
Bit depth : 8 bits
Compression mode : Lossless
Stream size : 3.80 MiB (100%)
This explains the file size diff between GUI (save frame) and cli output but not the overall png compression.
So just to confirm, this is the frame at t = 1, as rendered by ntsc-rs-cli -- --input /tmp/nanda_PAL.jpg --output /tmp/NANDA-0.png -p /tmp/nanda_initial.json --single-frame-time 1 -c png --compression-level 9:
For me, it's 1.05 MB:
$ mediainfo NANDA-0.png
General
Complete name : NANDA-0.png
Format : PNG
Format/Info : Portable Network Graphic
File size : 1.05 MiB
Image
Format : PNG
Format/Info : Portable Network Graphic
Compression : Deflate
Format settings : Linear
Width : 768 pixels
Height : 576 pixels
Display aspect ratio : 4:3
Color space : RGB
Bit depth : 8 bits
Compression mode : Lossless
Stream size : 1.05 MiB (100%)
Not sure what's going on here. Maybe I just need to bundle my own GStreamer libraries to avoid weird platform-specific codec differences?
Sounds like a gstreamer problem, because image, json, bash call, ntsc-rs-cli version, etc. are identical. Maybe it makes sense to do some static linking and provide a bundle. When there is time will try that on fedora on a different computer next few days.
Another thing is that this was done on a deb-multimedia-org gstreamer deb package env because there was no chance yet to properly downgrade from that repo. Trying to remove packages resulted in a huge amount of files to be uninstalled... still thinking how to do that in an elegant way without much effort to reinstall stuff. I will try on a different Debian without any foreign repos and sent a report here. Maybe native Debian will just work out. Ok?
Short update - using plain debian gstreamer libs (1.22.0-2+deb12uX) whereas X number differs in accordance to the lib itself, and the same jpg and profile it results in 2.20 MB -> the deb-multimedia.org gstreamer lib resulted in 2.23 MB (both with 640x480 resolution). Thus, there is no real difference.