Support and General Use > Audio Playback, Database and Playlists
Opus decoding and sample rate conversion
(1/1)
Julian67:
When I encode a 44100 Hz audio file with opusenc I know opus stores it as 48000 Hz. For playback on my PC I use ALSA with good quality sample rate conversion which defaults to converting to 44100.
If I play opus on a PC with
--- Code: ---opusdec track.opus --force-wav -| mplayer -
--- End code ---
I can see that the file is decoded to the original 44100 and there is no unusual load on the CPU. If I play it with ffplay (or anything other than opusdec) it decodes to 48000 Hz and there is a noticeable CPU load.
In Rockbox I notice the same opus audio file plays with "Show Track Info" displaying 48000 Hz sample rate. I have also seen stated that
--- Quote from: saratoga on January 08, 2010, 10:36:43 PM --- Resampling will result in reduced battery life, ... and greatly reduced audio quality in rockbox.
--- End quote ---
So my questions are:
Is Rockbox's "Show Track Info" correctly reporting 48000 Hz with opus files that opusdec would decode as 44100? In other words is Rockbox really just reporting the opus spec while not actually needing to run sample rate conversion?
If not then is it still the case that Rockbox's sample rate conversion is problematic in terms of either CPU load/battery life or audio quality?
I mostly use a Clip+ and as far as I can tell Rockbox doesn't use any CPU frequency scaling but instead runs at max frequency. Does this mean that any sample rate conversion doesn't make much difference to battery life on this device, or maybe I'm misunderstanding the issue?
saratoga:
--- Quote from: Julian67 on March 17, 2013, 06:27:34 PM ---Is Rockbox's "Show Track Info" correctly reporting 48000 Hz with opus files that opusdec would decode as 44100?
--- End quote ---
Opus only uses 48k, no other outputs are possible, so rockbox (correctly) reports that the sample rate is 48k. It'll then be resampled to 44.1k for playback after decode.
--- Quote from: Julian67 on March 17, 2013, 06:27:34 PM ---I mostly use a Clip+ and as far as I can tell Rockbox doesn't use any CPU frequency scaling but instead runs at max frequency. Does this mean that any sample rate conversion doesn't make much difference to battery life on this device, or maybe I'm misunderstanding the issue?
--- End quote ---
Opus is still pretty slow in rockbox since a lot of it hasn't been optimized, so battery life will probably be a lot worse then other formats.
Julian67:
Thanks.
I have a 44100 pcm wav file
--- Code: ---$ mediainfo 01\ -\ Introduction.wav
General
Complete name : 01 - Introduction.wav
Format : Wave
File size : 16.6 MiB
Duration : 1mn 38s
Overall bit rate mode : Constant
Overall bit rate : 1 411 Kbps
Audio
Format : PCM
Format settings, Endianness : Little
Format settings, Sign : Signed
Codec ID : 1
Duration : 1mn 38s
Bit rate mode : Constant
Bit rate : 1 411.2 Kbps
Channel(s) : 2 channels
Sampling rate : 44.1 KHz
Bit depth : 16 bits
Stream size : 16.6 MiB (100%)
--- End code ---
I encode it to opus:
--- Code: ---$ opusenc --bitrate 48 01\ -\ Introduction.wav 01\ -\ Introduction.opus
--- End code ---
--- Code: ---$ opusinfo 01\ -\ Introduction.opus
Processing file "01 - Introduction.opus"...
New logical stream (#1, serial: 427536f0): type opus
Encoded with libopus 1.1-alpha
User comments section follows...
ENCODER=opusenc from opus-tools 0.1.6
Opus stream 1:
Pre-skip: 356
Playback gain: 0 dB
Channels: 2
Original sample rate: 44100Hz
Packet duration: 20.0ms (max), 20.0ms (avg), 20.0ms (min)
Page duration: 1000.0ms (max), 998.0ms (avg), 800.0ms (min)
Total data length: 591007 bytes (overhead: 1.31%)
Playback length: 1m:38.773s
Average bitrate: 47.87 kb/s, w/o overhead: 47.24 kb/s
Logical stream 1 ended
--- End code ---
I play it:
--- Code: ---$ opusdec 01\ -\ Introduction.opus
Decoding to 48000 Hz (2 channels)
Encoded with libopus 1.1-alpha
ENCODER=opusenc from opus-tools 0.1.6
[-] 00:00:07
--- End code ---
or
--- Code: ---$ opusdec 01\ -\ Introduction.opus --force-wav -|mplayer -
Decoding to 44100 Hz (2 channels)
Encoded with libopus 1.1-alpha
ENCODER=opusenc from opus-tools 0.1.6
MPlayer2 UNKNOWN (C) 2000-2012 MPlayer Team
Playing -.
Reading from stdin...
Detected file format: WAV / WAVE (Waveform Audio) (libavformat)
[|] 00:00:05[wav @ 0x8771620]max_analyze_duration reached
[lavf] stream 0: audio (pcm_s16le), -aid 0
Load subtitles in .
Selected audio codec: Uncompressed PCM [pcm]
AUDIO: 44100 Hz, 2 ch, s16le, 1411.2 kbit/100.00% (ratio: 176400->176400)
AO: [alsa] 44100Hz 2ch s16le (2 bytes per sample)
[Mixer] No hardware mixing, inserting volume filter.
Video: no video
Starting playback...
^C 1.7 (01.7) of 12173.9 ( 3:22:53.9) 0.1%
--- End code ---
I decode the opus file back to wav:
--- Code: ---$ opusdec 01\ -\ Introduction.opus 01\ -\ Introduction_opus.wav
Decoding to 44100 Hz (2 channels)
Encoded with libopus 1.1-alpha
ENCODER=opusenc from opus-tools 0.1.6
Decoding complete.
--- End code ---
--- Code: ---$ mediainfo 01\ -\ Introduction_opus.wav
General
Complete name : 01 - Introduction_opus.wav
Format : Wave
File size : 16.6 MiB
Duration : 1mn 38s
Overall bit rate mode : Constant
Overall bit rate : 1 411 Kbps
Audio
Format : PCM
Format settings, Endianness : Little
Format settings, Sign : Signed
Codec ID : 1
Duration : 1mn 38s
Bit rate mode : Constant
Bit rate : 1 411.2 Kbps
Channel(s) : 2 channels
Sampling rate : 44.1 KHz
Bit depth : 16 bits
Stream size : 16.6 MiB (100%)
--- End code ---
So according to the opusdec printed output and the file written to disk, opusdec does sample rate convert to 44100 in some circumstances: "Decoding to 44100 Hz (2 channels)" and decodes without conversion in others "Decoding to 48000 Hz (2 channels)". It looks to me that when the original sample rate is known to be 44100 then either specifying --force-wav to stdout or writing to disk causes opusdec to decode to 44100 (whereas if I instead do 'ffmpeg -i <opus_file> -acodec pcm_s16le <wav_file>' I do indeed get a 48000 Hz wav).
For the sake of battery life I'll stick with 'lame --resample 22.05 -m m --abr 64' for audiobooks and similar mono files for the moment but it would be great if opus were a really practical option.
If opus' own sample rate converter is superior to Rockbox's then would it be possible for Rockbox to take advantage of that in future versions, decoding to 44100 and avoiding any possible sound quality and CPU loading issues?
saratoga:
It actually uses the libspeex one. I looked into integrating it, and its certainly possible. Just haven't had the time or interest lately.
Navigation
[0] Message Index
Go to full version