Beets: Beets uses (filesize / duration) as bitrate instead of audio stream bitrate

Created on 12 Jun 2020  Â·  9Comments  Â·  Source: beetbox/beets

Problem

I have a music library of ~20000 opus files and played a little with the embedart plugin yesterday. When embedding or clearing art from the media files themselves, obviously the file size changes. What I did not expect, however, was that a subsequent library update would adjust all the bitrates:

$ beet clearart
...

$ beet update
...
The Rolling Stones - The Rolling Stones - Honest I Do
  bitrate: 185kbps -> 156kbps
...

I think it's _technically_ correct to use the whole file for calculating the bitrate, but I think the more useful metric would be the bitrate of the audio stream in the container. At least I was surprised that beets did update the bitrate of my files due to embedding/clearing album art.

Setup

  • OS: Arch Linux
  • Python version: Python 3.8.3
  • beets version: beets version 1.4.9

  • Turning off plugins made problem go away (yes/no): the issue kind of depends on the embedart plugin

My configuration (output of beet config) is:

directory: ~/NC/Music
library: ~/.config/beets/library.db

import:
    move: yes

plugins: discogs embedart fetchart
embedart:
    auto: no
    maxwidth: 0
    compare_threshold: 0
    ifempty: no
    remove_art_file: no
fetchart:
    auto: yes
    minwidth: 0
    maxwidth: 0
    enforce_ratio: no
    cautious: no
    cover_names:
    - cover
    - front
    - art
    - album
    - folder
    sources:
    - filesystem
    - coverart
    - itunes
    - amazon
    - albumart
    google_key: REDACTED
    google_engine: REDACTED
    fanarttv_key: REDACTED
    store_source: no
discogs:
    apikey: REDACTED
    apisecret: REDACTED
    tokenfile: discogs_token.json
    source_weight: 0.5
    user_token: REDACTED
needinfo stale

Most helpful comment

Hi stale bot,
this issue depends on mutagen and I currently do not have time to implement it myself.
Have a nice day, stale bot

All 9 comments

Hello! This is true of file formats where Mutagen does not have the ability to read a "reported" metadata bitrate. We use this approximation as a fallback:
https://github.com/beetbox/mediafile/blob/a196016dc5ee3804134187874c11f3a1bd5cfaf2/mediafile.py#L2128-L2147

So unfortunately, where this happens, I don't think beets has any other option (other than reporting a zero bitrate or something).

We could guess more in mutagen and take the metadata into account. But in some cases this would also mean we guess wrong because we might include a video stream etc.

We can:

1) keep things as is
2) try to guess more in mutagen
3) same as (2) but indicate somewhere if the bitrate is exact

@jheyens Knowing which container/format this is about would help.

Hmm; good question. Maybe another option would be for Mutagen to report the size of the audio stream (or the metadata size) so clients can guess themselves if they want? It would seem to be a little confusing for Mutagen to offer "guessed" bitrates via the same API as "reported" bitrates, although of course that's exactly what beets does… :smiley:

Hi,
As I said above, all of my files are .opus files. Since it's usually vbr, even opusinfo will print average bitrate, but I think that would be most reasonable value to display. E.g. for the same file as in my initial issue report:

$ opusinfo 03\ Honest\ I\ Do.opus 
Processing file "..."...

New logical stream (#1, serial: cb9faa45): type opus
Encoded with Lavf58.29.100
User comments section follows...
...
Opus stream 1:
    Pre-skip: 312
    Playback gain: 0 dB
    Channels: 2
    Original sample rate: 48000 Hz
    Packet duration:   20.0ms (max),   20.0ms (avg),   20.0ms (min)
    Page duration:   1000.0ms (max),  995.6ms (avg),  420.0ms (min)
    Total data length: 2547128 bytes (overhead: 0.879%)
    Playback length: 2m:10.413s
    Average bitrate: 156.2 kbit/s, w/o overhead: 154.9 kbit/s
Logical stream 1 ended

I think, "Average bitrate w/o overhead: 154.9 kbit/s" would be the value I'ld choose.

As I said above, all of my files are .opus files.

Ah, somehow missed that, sorry. I'll have a look

Somehow this was never implemented, I've filed https://github.com/quodlibet/mutagen/issues/475

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Hi stale bot,
this issue depends on mutagen and I currently do not have time to implement it myself.
Have a nice day, stale bot

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings