TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Lossless audio compression with libpng

116 pointsby phoboslabalmost 11 years ago

14 comments

FlyingAvataralmost 11 years ago
FLAC is a streaming format. Each block of audio is compressed independently of the rest of the file.<p>Comparing it to any archival compression algorithm (PNG uses DEFLATE with some pre-filtering) is not an apples to apples comparison.<p>The utility of a streaming format is that, (a) your listeners can start the stream at any offset without having the preceding blocks, (b) the CPU overhead is generally stable and (c) decoding requires a minimal amount of memory and IO.
robrykalmost 11 years ago
I&#x27;ve done:<p><pre><code> sox piano.flac piano.wav gzip -c &lt; piano.wav &gt; piano.wav.gz brotli-encode &lt; piano.wav &gt; piano.wav.brotli ls -l piano2.wav piano2.wav.gz piano2.wav.brotli piano2.flac </code></pre> and gotten:<p><pre><code> -rw-r--r-- 1 robryk users 40056 Jun 14 19:15 piano2.wav.gz -rw-r--r-- 1 robryk users 87656 Jun 14 19:13 piano2.wav -rw-r--r-- 1 robryk users 34221 Jun 14 19:14 piano2.wav.brotli -rw-r--r-- 1 robryk users 52372 Jun 14 19:13 piano2.flac </code></pre> Either I&#x27;m doing something wrong or even plain gzip fares better than flac (edit: in this particular case, obviously). brotli-encode compresses using brotli[1] using the font mode.<p>[1] <a href="https://code.google.com/p/font-compression-reference/source/browse/#git%2Fbrotli" rel="nofollow">https:&#x2F;&#x2F;code.google.com&#x2F;p&#x2F;font-compression-reference&#x2F;source&#x2F;...</a>
评论 #7893367 未加载
评论 #7893366 未加载
foxhillalmost 11 years ago
a single test case hardly means &quot;beating&quot; FLAC. indeed, if you just wanted to encode a sine wave at one frequency for 30 seconds, your encoder would encode this as a couple of bytes - for any general compression codec there will be a problem class for which it will not be optimal.<p>that said, this approach may obviously be applied more generally, but it remains to be seen if it will perform so well. self-similarity seems so obvious as a compression technique that i would be.. surprised if this sort of compression wasn&#x27;t attempted before.
评论 #7893059 未加载
评论 #7893202 未加载
AceJohnny2almost 11 years ago
People forget one advantage of FLAC over other compression methods: it&#x27;s directly playable. You don&#x27;t need to decompress the whole thing before you can start playing it.<p>That&#x27;s an essential feature for a media compression format.
评论 #7893295 未加载
评论 #7894604 未加载
评论 #7893255 未加载
rb2k_almost 11 years ago
Interesting approach, but:<p>&gt; The sample audio I chose is one of the best case signals for this kind of compression, a single gradually decaying piano note.<p>Anyone know if this approach has any use in real-world scenarios?
评论 #7892852 未加载
评论 #7892859 未加载
评论 #7892875 未加载
评论 #7892906 未加载
AshleysBrainalmost 11 years ago
Are there any lossless compression algorithms that use autocorrelation to reduce the bit depth on repeated cycles? For example a human voice sustaining a note may have similar cycles, but with enough low-level noise-like variations that traditional deflate-type compression does not help much. However if an algorithm could spot that the second cycle only has small differences to the first cycle, perhaps it could encode the second cycle as a diff to the first cycle. Since the second cycle differences are likely to be small, the bit depth could be reduced (e.g. to 2-3 bits). Then the third cycle could also be encoded as a diff of the second, so even a gradually changing volume can be encoded with a very low bit rate throughout while ending up significantly different from the first cycle.<p>Has that been tried before? Would be willing to spend a few evenings hacking on this myself.
评论 #7893868 未加载
评论 #7893199 未加载
评论 #7893154 未加载
eliteraspberriealmost 11 years ago
To improve the calculation of the autocorrelation, first &#x27;demean&#x27; the input sequence by subtracting its mean from it, like so: <a href="https://gist.github.com/anonymous/a293bdbfa9133a607dd1" rel="nofollow">https:&#x2F;&#x2F;gist.github.com&#x2F;anonymous&#x2F;a293bdbfa9133a607dd1</a><p>The reason being that autocorrelation (and convolution in general) is meaningful when the input signal is linear time invariant. Read more about that here: <a href="https://en.wikipedia.org/wiki/LTI_system_theory#Impulse_response_and_convolution_2" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;LTI_system_theory#Impulse_resp...</a>
dtechalmost 11 years ago
Now while my intuition would certainly say that autocorrelation is a good candidate property to be used in (lossless) audio compression, I remain sceptical.<p>It is certainly not a recently discovered or difficult concept to grasp, so if it was that useful I would think that it was already included in things like FLAC...
评论 #7893029 未加载
qq66almost 11 years ago
Fun, but a good media compression format has other properties like: 1) low cost of decoding in terms of RAM&#x2F;CPU etc. 2) ability to decompress an arbitrary amount of the audio from any starting point in the file, 3) ability to start decoding before the entire file is present.
aobukealmost 11 years ago
What are difference between audio-based and fit-based compression method? These two can transform easily...
zbowlingalmost 11 years ago
What kind of weissman score does this get?
评论 #7895196 未加载
评论 #7893552 未加载
billylindemanalmost 11 years ago
But what is its weissman score?
评论 #7893037 未加载
marksands07almost 11 years ago
Wow, a Weissman Score of 5.2!
aobukealmost 11 years ago
Jj