xiph / libopusenc

Library for encoding .opus audio files and live streams.
BSD 3-Clause "New" or "Revised" License
108 stars 39 forks source link

Are there technical limitations for opusenc running indefinitely? #25

Closed guest271314 closed 3 years ago

guest271314 commented 3 years ago

opusenc documentation includes this at NOTES

While it is possible to use opusenc for low latency streaming (e.g. with --max-delay 0 and netcat instead of Icecast) it's not really designed for this, and the Ogg container and TCP transport aren't the best tools for that application. Shell pipelines themselves will often have high buffering. The ability to set framesizes as low as 2.5 ms in opusenc mostly exists to try out the quality of the format with low latency settings, but not really for actual low latency usage. Interactive usage should use UDP/RTP directly.

For the use case of a user-defined infinite stream, that is, using the output of opusenc as the source of a Web radio station, are there any technical limitations for the configuration of using a dedicated Linux machine to run opusenc indefinitely, commenced from a shell script e.g.,

<?php 
  if (isset($_GET["start"])) {
    header("Access-Control-Allow-Origin: *");
    header("Content-Type: audio/x-opus+ogg");
    echo passthru("parec -v --record --rate=48000 --device=alsa_output.pci-0000_00_N.analog-stereo.monitor | opusenc --expect-loss=25 --max-delay=0 --framesize=2.5 --bitrate=256 --raw - -");
    exit();
  }
document.querySelector('audio').src = 'index.php?start=true';
guest271314 commented 3 years ago

I ran opusenc for over 19 hours https://gist.github.com/guest271314/551776848895d972c9cbb8563a2acde5. That is sufficient for an initial test case.

rillian commented 3 years ago

Glad you got it working!

BTW, your shouldn't need to pass any options to opusenc beyond bitrate. The switches are generally for specialized applications. It's already tuned for web streaming, so setting --expect-loss or --framesize will hurt quality without offering any benefit for http streams.