[opus] Audacity adds noise to silence! (Was: Why silence is encoded with so many bits?)
Jesus Cea
jcea at jcea.es
Mon Apr 19 18:54:59 UTC 2021
On 17/4/21 2:40, Emily Bowman wrote:
> That would be highly unusual. Can you give us a sample of the output and
> the commandline or call to the encoder? My suspicion is that it might be
> in CBR mode using padding bits.
Steps to reproduce:
1. Open audacity: https://www.audacityteam.org/
2. Create an audio of a minute of absolute silence.
3. Export as WAV.
4. From the command line, write "opusenc silence.wav silence.opus". The
output:
"""
jcea at jcea:/tmp/ram$ opusenc silence.wav silence.opus
Encoding using libopus 1.3.1 (audio)
-----------------------------------------------------
Input: 44.1 kHz, 1 channel
Output: 1 channel (1 uncoupled)
20ms packets, 64 kbit/s VBR
Preskip: 312
Encoding complete
-----------------------------------------------------
Encoded: 1 minute and 0.02 seconds
Runtime: 0 seconds
Wrote: 422950 bytes, 3001 packets, 63 pages
Bitrate: 55.6429 kbit/s (without overhead)
Instant rates: 42.4 to 86.4 kbit/s
(106 to 216 bytes per packet)
Overhead: 1.3% (container+metadata)
jcea at jcea:/tmp/ram$ ls -la silence.*
-rw-rw-r-- 1 jcea jcea 422950 abr 19 17:30 silence.opus
-rw-rw-r-- 1 jcea jcea 5292044 abr 19 17:28 silence.wav
"""
A minute of absolute silence is encoded as a 422Kbytes file, 55Kbps
bitrate!.
Studying the audacity generated WAV file, I noticed it is not actually
absolute silence!. It is a very faint noise. For instance, exporting a
16 bits PCM audio WAV file and checking the file by hand I see values
+-3 at random. The last three bits seems random. Maybe Audacity is
adding dithering when exporting to WAV. That "dithering" is done even
when exporting to 32 bit float wav.
With this new realization, I looked up "audacity wav export dithering"
and I got this webpage: https://manual.audacityteam.org/man/dither.html
In that page they say that dithering is applied in all exports except 32
bits PCM audio... but "opusenc" notably doesn't supports that format:
"""
jcea at jcea:/tmp/ram$ opusenc silence.wav silence.opus
ERROR: Unsupported WAV sample size.
Must be 8, 16, or 24 bit PCM or 32 bit floating point PCM.
Error: unsupported input file: silence.wav
"""
Disabling dithering and exporting a REAL silence, I get a bitrate of
1.2Kbps. That seems pretty acceptable.
Sorry for wasting your time, but I think this email might be useful to
other people.
Thanks.
PS: Would be interesting to use "OPUS_SET_LSB_DEPTH" ctl call to signal
"signal under x dB is silence": "opusenc --set-ctl-int 4036=12
silence.wav silence.opus". I don't know if Opus would just use "12 bits"
or rather consider silence if the signal power is below 12 bits, but use
the full range when signal is present. If it is the second case, I could
even use only 8 bits for silence detection, but encode 16 bits when
signal is present.
--
Jesús Cea Avión _/_/ _/_/_/ _/_/_/
jcea at jcea.es - https://www.jcea.es/ _/_/ _/_/ _/_/ _/_/ _/_/
Twitter: @jcea _/_/ _/_/ _/_/_/_/_/
jabber / xmpp:jcea at jabber.org _/_/ _/_/ _/_/ _/_/ _/_/
"Things are not so easy" _/_/ _/_/ _/_/ _/_/ _/_/ _/_/
"My name is Dump, Core Dump" _/_/_/ _/_/_/ _/_/ _/_/
"El amor es poner tu felicidad en la felicidad de otro" - Leibniz
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature
Type: application/pgp-signature
Size: 495 bytes
Desc: OpenPGP digital signature
URL: <http://lists.xiph.org/pipermail/opus/attachments/20210419/03fef219/attachment.sig>
More information about the opus
mailing list