Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for arbitrarily high framesize? #32

Closed
Qwertylex opened this issue Feb 4, 2017 · 9 comments
Closed

Support for arbitrarily high framesize? #32

Qwertylex opened this issue Feb 4, 2017 · 9 comments

Comments

@Qwertylex
Copy link

I'm trying to experiment with extremely low bitrates and would like to set my frame size to 1000 ms or higher, even if that sounds crazy to you.

@Qwertylex
Copy link
Author

opusenc opus-tools 0.1.9 (using libopus 1.1.4)

only supports up to 60ms framesize

@Qwertylex
Copy link
Author

actually I should have compiled your latest git before opening this issue...

@Qwertylex
Copy link
Author

libopus 1.2-alpha2-4-gcfdaf365
Unsupported frame size: 1200 ms. Supported are 2.5, 5, 10, 20, 40, 60, 80, 100, 120.

@Qwertylex
Copy link
Author

Qwertylex commented Feb 4, 2017

$ ./opus_demo -e audio 48000 1 16000 -cbr -framesize 120 Anuna\ 48k.wav anuna.opus
libopus 1.2-alpha2-4-gcfdaf365
Encoding 48000 Hz input at 16.000 kb/s in auto bandwidth with 5760-sample frames.
average bitrate: 16.000 kb/s
maximum bitrate: 16.000 kb/s
active bitrate: 16.000 kb/s
bitrate standard deviation: 0.000 kb/s
$ file anuna.opus
anuna.opus: data
$ mpv anuna.opus
Playing: anuna.opus
Failed to recognize file format.

whats going on here?

@rillian
Copy link
Contributor

rillian commented Feb 4, 2017

opus_demo doesn't make .opus files. It uses a custom format just for testing. You need to use opusenc from the opus-tools package to create files other applications can play.

@rillian
Copy link
Contributor

rillian commented Feb 4, 2017

I'm trying to experiment with extremely low bitrates and would like to set my frame size to 1000 ms or higher, even if that sounds crazy to you.

This isn't possible in the opus bitstream. As the encoder reported, 120 ms is the maximum duration of a single frame/packet. At that point there's no meaningful reduction in overhead for encoding longer frames. Meanwhile, longer frames reduce quality by preventing the encoder from switching modes as the character of the audio changes.

The default 20 ms frame size was chosen as the best trade-off between encoding latency and framing overhead. If you're making .opus files and don't care about encoding latency, then that works well. For RTP longer frames are helpful when bitrate is more important than latency, because the framing overhead is so much larger than in .opus.

@Qwertylex
Copy link
Author

Thank you for your input!
opusenc does not yet support 120ms frames however...

@Qwertylex
Copy link
Author

Meanwhile, longer frames reduce quality by preventing the encoder from switching modes as the character of the audio changes.

Ah so that explains what I was noticing.

Anyway.
https://wiki.xiph.org/OpusFAQ#What_frame_size_should_I_use.3F

Smaller frame sizes may be used to achieve lower latency, but have lower quality at a given bitrate.

... So I assumed the inverse was true, that larger framesizes (>20) would be better at a low bitrate...

I re-encoded some flac to 16kbps 2.5, 5, 20, 40, 60ms framesizes
( https://anuna.bandcamp.com/track/s-do-mhaimeo )
2.5 sounded like a robot drowning down a deep well
5 sounded like it had lost all high frequency sounds
20 sounded like what you'd expect for 16kbps opus
40 sounded like 20 but sounded like it was breaking up/ kinda choppy sounding
60 sounded like it was clipping waveforms

assuming that higher framesizes are supposed to sound better, I figured maybe it is just giving me higher frequencies and thus I'm hearing more artifacts, so I was curious as to what 1000ms would sound like.

@jmvalin
Copy link
Member

jmvalin commented Feb 13, 2017

Note that unless you're using RTP and the related header overhead, you're not gaining anything from using frame sizes larger than 20 ms. If your application is encoding low bitrate music to file, then the best frame size to use is 20 ms, not 60 ms, not 120 ms. Using larger frame sizes just concatenates 20 ms frames, but it prevents the encoder from making optimal decisions.

@jmvalin jmvalin closed this as completed Feb 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants