-3

Can anyone offer me pointers or tips on finding/creating a data compression algorithm that has a guaranteed compression ratio? Obviously this couldn't be a loss-less algorithm.

My question is similar to the one here, but there was no suitable answer:

Shrink string encoding algorithm

What I am trying to do is stream live audio over a wireless network (my own spec, not WiFi) with a tight bandwidth restriction. Let's say I have packets 60 bytes in size. I need an algorithm to compress these to, say, 35 bytes every time without fail. Reliable guaranteed compression to a fixed size is key. Audio quality is less of a priority.

Any suggestions or pointers? I may end up creating my own algorithm from scratch, so even if you don't know of any libraries or standard algorithms, I would be grateful for brilliant ideas of any kind!

Community
  • 1
  • 1
Ben Hershey
  • 350
  • 3
  • 8
  • Possible duplicate of [Shrink string encoding algorithm](http://stackoverflow.com/questions/20765078/shrink-string-encoding-algorithm) – Chewpers Mar 03 '16 at 21:15
  • 3
    Why is searching for "constant bitrate audio" not helping? Is there some reason you can't just use ffmpeg? – rici Mar 03 '16 at 22:24
  • Fractal compression perhaps? :) – marko Mar 03 '16 at 22:27

1 Answers1

2

It is good that you mentioned your use case: live audio.

There are many audio CODECs (COder-DECoder) that work exactly this way (constant bit-rate). For example, take a look at Opus. You can select bitrates from 6 kb/s to 510 kb/s, and frame sizes from 2.5 ms to 60 ms.

I used it in the past to tranfer audio over RF datalinks. You'll probably need to implement a de-jitter buffer as well (see more here). Also note that the internal clock of many sound cards is not accurate, and there may be a "drift" between the source and target rate (e.g. a 30mSec buffer may be played in 29.9mSec or 30.1mSec) and you may need to compensate for this as well.

Lior Kogan
  • 19,919
  • 6
  • 53
  • 85