Opus files are encoded in hard-CBR

Bug #1097610 reported by qduaty on 2013-01-09
20
This bug affects 4 people
Affects Status Importance Assigned to Milestone
SoundConverter
Medium
GautierPortet
soundconverter (Debian)
Fix Released
Unknown
soundconverter (Ubuntu)
Undecided
Unassigned

Bug Description

Opusinfo tool shows that OPUS files produced by soundconverter use hard-CBR mode (instead of VBR).

Changed in soundconverter (Ubuntu):
assignee: nobody → GautierPortet (kassoulet)
Changed in soundconverter:
assignee: nobody → GautierPortet (kassoulet)
Changed in soundconverter (Ubuntu):
assignee: GautierPortet (kassoulet) → nobody
Changed in soundconverter:
status: New → Confirmed
GautierPortet (kassoulet) wrote :

So I have to add cbr=false to opusenc. But there is a big problem here. It crashes GStreamer...

Changed in soundconverter:
importance: Undecided → Medium
Changed in soundconverter:
status: Confirmed → In Progress
Changed in soundconverter:
status: In Progress → Confirmed
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in soundconverter (Ubuntu):
status: New → Confirmed
Lem (lem-jjr) wrote :

Soundconverter 2.1.2, in gstreamer.py, line 668 and 669:

def add_opus_encoder(self):
        return 'opusenc bitrate=%s cbr=false ! oggmux' % (self.opus_quality * 1000)

Adding cbr=false seemed to result in a different output.

Encoded on Ubuntu 13.10 (unsure whether soundconverter 2.1.2 from source is using gstreamer 0.10 or 1.0), before adding cbr=false:
$ opusinfo 03\ -\ North\ Bound\ \(1\).opus
Processing file "03 - North Bound (1).opus"...

New logical stream (#1, serial: 7dc771f2): type opus
WARNING: Implausibly low preskip in Opus stream (1)
Encoded with Encoded with GStreamer Opusenc
User comments section follows...
 TITLE=North Bound
 ARTIST=Tony O'Connor
 ALBUM=Seashore Sunrise
 DISCNUMBER=1
 DATE=1991-01-01
 TRACKNUMBER=3
 TRACKTOTAL=6
 GENRE=New Age
 DESCRIPTION=EAC FLAC -8
 COMMENT=EAC FLAC -8
Opus stream 1:
 Pre-skip: 0
 Playback gain: 0 dB
 Channels: 2
 Original sample rate: 48000Hz
 Packet duration: 20.0ms (max), 20.0ms (avg), 20.0ms (min)
 Page duration: 260.0ms (max), 259.9ms (avg), 120.0ms (min)
 Total data length: 5129508 bytes (overhead: 1.26%)
 Playback length: 5m:16.539s
 Average bitrate: 129.6 kb/s, w/o overhead: 128 kb/s (hard-CBR)
Logical stream 1 ended

After adding cbr=false:

$ opusinfo 03\ -\ North\ Bound\ \(2\).opus
Processing file "03 - North Bound (2).opus"...

New logical stream (#1, serial: 658e5e51): type opus
WARNING: Implausibly low preskip in Opus stream (1)
Encoded with Encoded with GStreamer Opusenc
User comments section follows...
 TITLE=North Bound
 ARTIST=Tony O'Connor
 ALBUM=Seashore Sunrise
 DISCNUMBER=1
 DATE=1991
 TRACKNUMBER=3
 TRACKTOTAL=6
 GENRE=New Age
 DESCRIPTION=EAC FLAC -8
 COMMENT=EAC FLAC -8
Opus stream 1:
 Pre-skip: 0
 Playback gain: 0 dB
 Channels: 2
 Original sample rate: 48000Hz
 Packet duration: 20.0ms (max), 20.0ms (avg), 20.0ms (min)
 Page duration: 280.0ms (max), 261.2ms (avg), 220.0ms (min)
 Total data length: 5145176 bytes (overhead: 1.26%)
 Playback length: 5m:16.539s
 Average bitrate: 130 kb/s, w/o overhead: 128.4 kb/s
Logical stream 1 ended

However using opusenc (opus-tools 0.1.8) with --bitrate=128, I get a different file again:
$ opusinfo 03\ -\ North\ Bound.flac.opus
Processing file "03 - North Bound.flac.opus"...

New logical stream (#1, serial: 126ed0e5): type opus
Encoded with libopus 1.1
User comments section follows...
 ENCODER=opusenc from opus-tools 0.1.8
 ENCODER_OPTIONS=--bitrate 128
 TITLE=North Bound
 ARTIST=Tony O'Connor
 ALBUM=Seashore Sunrise
 DISCNUMBER=1
 DATE=1991
 TRACKNUMBER=03
 TRACKTOTAL=06
 GENRE=New Age
 DESCRIPTION=EAC FLAC -8
 COMMENT=EAC FLAC -8
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.6ms (avg), 560.0ms (min)
 Total data length: 5431593 bytes (overhead: 0.763%)
 Playback length: 5m:16.533s
 Average bitrate: 137.3 kb/s, w/o overhead: 136.2 kb/s
Logical stream 1 ended

Anyway, the different size/bitrate files might be due to opus version. But, was it really that simple to just add cbr=false?

Lem (lem-jjr) wrote :

Oops, I forgot that adding cbr=false crashes Soundconverter. From the debug log:

launching: 'giosrc location="file:///media/Arch/Audio/FLAC/New_Age/Tony_O'Connor/Tony%20O'Connor%20-%20Seashore%20Sunrise%20(1991)%20%5BFLAC%5D/03%20-%20North%20Bound.flac" name=src ! decodebin name=decoder ! audiorate ! audioconvert ! audioresample ! opusenc bitrate=128000 cbr=false ! oggmux ! giosink location="file:///media/Space/Audio/Opus_Transcodes/1/Unknown%20Artist-Unknown%20Album/03%20-%20North%20Bound.opus.opus~SC~"'
Segmentation fault (core dumped)

I actually then launched the above command with gst-launch-1.0, that worked.

One more thing about the output from opusdec above, I noticed that the files were 48kHz (the source is definitely 44.1kHz), but I didn't have resampling enabled. opusenc itself didn't resample the FLAC to 48kHz.

GautierPortet (kassoulet) wrote :

So hopefully this will be solved by using gstreamer 1.0...

Changed in soundconverter:
milestone: none → 3.0
Changed in soundconverter:
status: Confirmed → In Progress
wayne (mathwhiz1212) wrote :

I can't use soundconverter for conversion if this is the case. Wouldn't opusenc --vbr work?

Just wanted to chime in. I needed to convert some music today and your tool worked almost perfectly for me. :+1:

Regarding this issue: I'm using `soundconverter` 3.0.0~alpha1+git20151209-1 with GStreamer 1.0 from Debian Multimedia and tried to convert some 320 MP3s into Opus. However I got an error message when I tried to do so:

    GStreamer error when creating pipeline
    gst_parse_error: no property "cbr" in element "opusenc3" (2)

After finding this issue, I did a short investigation and it turns out that the `cbr` option does not exist in GStreamer 1.0; instead the `bitrate-type` option was introduced:

    bitrate-type : Bitrate type
                         flags: readable, writable, changeable in NULL, READY, PAUSED or PLAYING state
                          Enum "GstOpusEncBitrateType" Default: 0, "cbr"
                             (0): cbr - CBR
                             (1): vbr - VBR
                             (2): constrained-vbr - Constrained VBR

Replacing `cbr=false` with `bitrate-type=vbr` resulted in a proper VBR Opus being generated:

    Processing file "10 Running In Place.opus"...

    New logical stream (#1, serial: 30e48d71): type opus
    Encoded with Encoded with GStreamer opusenc
    User comments section follows...
            ALBUM=Feeding The Wolves (Deluxe Edition)
            ALBUMARTIST=10 Years
            ARTIST=10 Years
            COMMENT=0
            DATE=2010
            DISCNUMBER=1
            DISCTOTAL=1
            GENRE=Rock
            METADATA_BLOCK_PICTURE=3|image/jpeg||0x0x0|<20581 bytes of image data>
            TITLE=Running In Place
            TRACKNUMBER=10
    Opus stream 1:
            Pre-skip: 312
            Playback gain: 0 dB
            Channels: 2
            Original sample rate: 48000Hz
            Packet duration: 20.0ms (max), 20.0ms (avg), 20.0ms (min)
            Page duration: 520.0ms (max), 185.3ms (avg), 120.0ms (min)
            Total data length: 5144236 bytes (overhead: 1.6%)
            Playback length: 3m:35.875s
            Average bitrate: 190.6 kb/s, w/o overhead: 187.6 kb/s
    Logical stream 1 ended

GautierPortet (kassoulet) wrote :
Changed in soundconverter:
status: In Progress → Fix Committed
milestone: 3.0 → 3.0.0-beta2
Changed in soundconverter (Debian):
status: Unknown → New
Changed in soundconverter (Debian):
status: New → Fix Released
Sebastian Ramacher (s-ramacher) wrote :

Fixed in 3.0.0~beta1-1.

Changed in soundconverter (Ubuntu):
status: Confirmed → Fix Released
Changed in soundconverter:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Related blueprints

Remote bug watches

Bug watches keep track of this bug in other bug trackers.