How to use iqzip?

My station saves all IQ files to my Dropbox account. To save storage space and bandwidth, the IQ files are compressed with xz.

Now that iqzip is available, I thought I’d see if I could switch to iqzip instead of xz. I compiled and installed the iqzip library, and the iqzip example app. I then tried compressing a wav file:

~/iqzip/apps/build/iqzip 4060852_NANOCONNECT-2SAI-1.wav 4060852_NANOCONNECT-2SAI-1.wav.iqz

The result was a slightly larger file:

-rw-r--r--   1 pi pi  63M Dec  7 15:41 4060852_NANOCONNECT-2SAI-1.wav
-rw-r--r--   1 pi pi  64M Dec  7 15:42 4060852_NANOCONNECT-2SAI-1.wav.iqz
-rw-r--r--   1 pi pi  43M Dec  7 15:40 4060852_NANOCONNECT-2SAI-1.wav.xz

I expected a file that would be smaller than the original file. Maybe not as small as the xz file, but I expected some sort of compression.

Is this not the right way to use iqzip?

I see that there has been no updates to the iqzip repo for 2 years. Is iqzip a dead end? Should I use something else?

You are using wav or iq_dump raw ?
I have been using zstd on iq_dump, usually compresses them down to around 25% of the original size.

50M Jan  3 17:20 iq_6975024_57600.raw
12M Jan  3 17:20 iq_6975024_57600.raw.zst

I have it running in a crontab

#!/bin/bash
# cwd to dir where the script is located
cd "$(dirname "${0}")" || exit
FILES=(*.raw)
# check if glob expanded to a file list
if [ ! -f "${FILES[0]}" ]; then exit; fi
for f in "${FILES[@]}"; do
    zstd --rm -f "${f}"
done

Tack SA2KNG

Yes, I am using the raw iq files.

Unfortunately, it seems like zstd is performing considerably worse than xz (at least when using the standard settings for xz and zstd), at least for the files I tried:

File Original size Compressed size flac Flac ratio Compressed size xz -6 xz ratio Compressed size zstd zstd ratio Compressed size zstd -19 zstd -19 ratio
6750181_0_UVSQ-SAT.wav 89046800 47608484 53,5% 53158044 59,7% 61286795 68,8% 59189863 66,5%
6761957_0_UVSQ-SAT.wav 89955460 49148800 54,6% 54755016 60,9% 62813458 69,8% 58577089 65,1%
6915601_0_DSAT.wav 59878656 32149909 53,7% 35905036 60,0% 41314881 69,0% 38076911 63,6%
6916490_UVSQ-SAT.wav 85051672 46996343 55,3% 52051304 61,2% 59601060 70,1% 56359490 66,3%
6924496_0_NETSAT-2.wav 57384288 30086094 52,4% 33682040 58,7% 38971186 67,9% 36412881 63,5%
6929658_0_KKS-1_KISEKI.wav 68155148 34997790 51,4% 39136216 57,4% 45658157 67,0% 42512620 62,4%
6930693_0_TAURUS-1.wav 125965520 69058161 54,8% 76607548 60,8% 87767997 69,7% 82048056 65,1%
6931543_0_NEXUS.wav 51620956 28644598 55,5% 31685564 61,4% 36285008 70,3% 33540367 65,0%
6953937_0_BY70-2.wav 107504300 57741229 53,7% 64451248 60,0% 74149147 69,0% 69856033 65,0%

So far, it looks like flac is the winner. It is also considerably faster than xz. But it would be nice to use iqzip, since it includes metadata. I’m curious to why I’m getting so much worse zstd compression ratio than you do though.

Edit: Added test results for zstd -19

I’m cc’ing @ctriant and @sdoukos that have developed iqzip.

Hello @mfalkvidd.
The iqzip is not a dead project, it is considered completed so there is no active development for extra features right now.

The problem is that the default options of iqzip does not correspond to the file characteristics from the iq dump e.g bits per sample, if samples are signed etc.
The command for your example should be:

~/iqzip/apps/build/iqzip -s -n 16 4060852_NANOCONNECT-2SAI-1.wav 4060852_NANOCONNECT-2SAI-1.wav.iqz

Hope that works as expected!

1 Like

Great, thanks! I’ll test and report back with the results.

These are the results with iqzip:

File Flac xz zstd zstd -19 iqzip
6750181_0_UVSQ-SAT.wav 53,5% 59,7% 68,8% 66,5% 59,7%
6761957_0_UVSQ-SAT.wav 54,6% 60,9% 69,8% 65,1% 60,9%
6915601_0_DSAT.wav 53,7% 60,0% 69,0% 63,6% 60,2%
6916490_UVSQ-SAT.wav 55,3% 61,2% 70,1% 66,3% 61,1%
6924496_0_NETSAT-2.wav 52,4% 58,7% 67,9% 63,5% 58,4%
6929658_0_KKS-1_KISEKI.wav 51,4% 57,4% 67,0% 62,4% 57,4%
6930693_0_TAURUS-1.wav 54,8% 60,8% 69,7% 65,1% 61,0%
6931543_0_NEXUS.wav 55,5% 61,4% 70,3% 65,0% 62,0%
6953937_0_BY70-2.wav 53,7% 60,0% 69,0% 65,0% 60,3%
Average 53,9% 60,0% 69,1% 64,7% 60,1%

So for this dataset, iqzip compresses very close to xz. flac is the winner and zstd the loser. I also noticed that iqzip is very fast, close to flac in compression speed.

I’m still curious why SA2KNG got so much better compression with zstd. Maybe the reason stems from him using plutosdr while I’m using RTL-SDR?

I’m also a bit surprised that the raw iq files are 16-bit when RTL-SDR is only 8-bit. My guess is that Satnogs uses 16-bit regardless of what SDR is used. But in that case, it should be possible to compress IQ files from RTL-SDR 50% since half the bits would be zero? Or is decimation used to increase the resolution?

Nice work with the comparisons!

FLAC was also very good in our comparisons, although Iqzip, which uses the Shorten compression algorithm, was better in our dataset for most observations. The comparisons can be found here.
Also Iqzip is a CCSDS compliant compression scheme that can be used in space missions, and that is another important aspect of our compression scheme.

I also tried to tune some parameters of the algorithm but it seems there is a bug in the application we provide. Let me fix it and i will come back with my results with tuned parameters.

2 Likes

Sa2kng was kind enough to share his iq file. Here are the compression results with the same settings as my other tests.

File Flac xz zstd zstd -19 iqzip
6979979_48000 (SA2KNG) 21,7% 17,2% 22,7% 18,3% 21,7%
2 Likes

@sdoukos have you had a chance to look at the bug?

Hello. Sorry for the delay, have not looked into it yet but i will try to fix it in the weekend.

No worries. Just curious what you have found :slight_smile:

Just checking if you’ve been able to look into the bug @sdoukos

Hello again.

Firstly i have tested it a bit and i have found that the biggest block -j that works is 128 and reference interval -r is 128. The default values are -j 64 -r 1, and the difference in size for the default and biggest parameters allowed using 1574048_AAUSAT_4.wav file for testing is 1MB (142MB original size, 80 MB and 79 MB compressed respectively). This behaviour is known as you can see here.

When i talked about a bug in our app it was a misconception on my part because i was talking about extended block size parameters and not rsi values. At some point we decided to remove the libaec as a submodule of the project and as a result changes that we made to libaec regarding the maximum block size were removed. As can be seen from our measurements, using higher values for block size than 64 does not effect compression ratio that much, hence we made that decision.

I am currently investigating why “legal” rsi values don’t work as expected. I have found a solution on compression but using an rsi of 4096 has a miniscule difference of 4 KB compared to 128.

With that in mind i would say that FLAC works better in those observations because it just does as seen in some observations on our own testing but it is not CCSDS compatible as i stated in my previous post.

Now i will try to fix the bug with rsi > 128 hopefully by the end of the week. Then i test the libaec a bit to see if we could support higher block sizes (iqzip can and should but i won’t explain it in depth in this post because i don’t remember exactly how the headers save “illegal” values) and i will update documentation and maybe measurements because even me had problems to read the charts and i have written them :stuck_out_tongue:

2 Likes

Is there a way to instruct iqzip to output to stdout instead of a file?

Use case: I want to stream the output to dropbox (via rclone) to lower the amount if space required on tmpfs. Currently, tmpfs needs to store original iq file + compressed iq file.

Edit: I checked the source code it it doesn’t seem to be possible at the moment. Adding support will probably requiring changing all the error messages printed throughout the library to std::cout to use std::cerr instead but I am not sure what side effect that would have.

For now I have switched back to using xz instead.

iqzip supports streaming compression with the use of stream_compress function that maybe could work for you. Right now there is no example of using the stream compression feature but there is an open issue here.

As i am currently working on iqzip again it might be created but i cannot give a timeline for now.

2 Likes