beetbox / beets

music library manager and MusicBrainz tagger
http://beets.io/
MIT License
12.73k stars 1.82k forks source link

convert plugin copies replaygain tags into opus files, instead of using R128 tags #2945

Closed cstoitner closed 4 years ago

cstoitner commented 6 years ago

Problem

When converting flac files to opus, the previously generated replaygain tags get copied over to the opus files. Opus files should use R128 tags instead (see https://github.com/beetbox/beets/issues/2557).

Setup

My configuration (output of beet config) is:

mpd:
    port: 6600
    host: REDACTED
    password: REDACTED
lyrics:
    bing_lang_from: []
    force: no
    auto: yes
    genius_api_key: REDACTED
    google_engine_ID: REDACTED
    sources:
    - google
    - lyricwiki
    - musixmatch
    - genius
    bing_lang_to:
    bing_client_secret: REDACTED
    google_API_key: REDACTED
    fallback:
    local: no
asciify_paths: yes
art_filename: cover
replaygain:
    backend: bs1770gain
    method: ebu
    overwrite: yes
    targetlevel: 89
    auto: yes
    r128: [Opus]
    chunk_at: 5000

plugins: fetchart lastimport lyrics mbsync zero the thumbnails replaygain scrub mpdupdate convert importadded

ui:
    color: yes

import:
    move: yes
thumbnails:
    force: yes
    dolphin: yes
    auto: yes

paths:
    default: '%the{$albumartist}/$album %aunique{}/$track. $title'
    quarantine:true singleton:true: _quarantine/_non album/%the{$artist}/$title
    quarantine:true comp:true: _quarantine/_various artists/$album %aunique{}/$track. $title
    quarantine:true: _quarantine/%the{$albumartist}/$album %aunique{}/$track. $title
    singleton: _non album/%the{$artist}/$title
    comp: _various artists/$album %aunique{}/$track. $title
convert:
    dest: /mnt/enclave/share/Media/Audio/convertedMusic
    never_convert_lossy_files: yes
    copy_album_art: yes
    album_art_maxwidth: 1080
    embed: no
    format: opus
    formats:
        opus:
            command: opusenc --bitrate 192 "$source" "$dest"
            extension: opus.ogg
        alac:
            command: ffmpeg -i $source -y -vn -acodec alac $dest
            extension: m4a
        aac:
            command: ffmpeg -i $source -y -vn -acodec aac -aq 1 $dest
            extension: m4a
        mp3: ffmpeg -i $source -y -vn -aq 2 $dest
        flac: ffmpeg -i $source -y -vn -acodec flac $dest
        ogg: ffmpeg -i $source -y -vn -acodec libvorbis -aq 3 $dest
        wma: ffmpeg -i $source -y -vn -acodec wmav2 -vn $dest
    auto: no
    threads: 8
    tmpdir:
    max_bitrate: 500

    paths: {}
    pretend: no
    quiet: no
    no_convert: ''
per_disc_numbering: no
zero:
    fields: [comments]
    comments:
    - EAC
    - LAME
    - CUERipper
    - from.+collection
    - ripped by
    - encoded by
    - \.com
    - \.de
    - \.net
    - \.org
    - Track \d+
    auto: yes
    update_database: no
    keep_fields: []
lastgenre:
    count: 3
    separator: ;
    whitelist: ~/.config/beets/genres.txt
    canonical: ~/.config/beets/canonicalGenres.yaml
directory: /mnt/enclave/share/Media/Audio/Music
lastfm:
    user: REDACTED
    api_key: REDACTED
the:
    a: yes
    the: yes
    patterns: [^der, ^die, ^das]
    strip: no
    format: '{0}, {1}'
mpdupdate:
    host: REDACTED
    port: 6600
lastimport:
    per_page: 500
    retry_limit: 3
fetchart:
    auto: yes
    minwidth: 0
    sources:
    - filesystem
    - coverart
    - itunes
    - amazon
    - albumart
    google_engine: 001442825323518660753:hrh5ch1gjzm
    enforce_ratio: no
    cautious: no
    maxwidth: 0
    store_source: no
    google_key: REDACTED
    fanarttv_key: REDACTED
    cover_names:
    - cover
    - front
    - art
    - album
    - folder
importadded:
    preserve_write_mtimes: no
    preserve_mtimes: no
scrub:
    auto: yes
sampsyo commented 6 years ago

Hi! Interesting point, but what do you propose to do in this case? When we scan Vorbis files in the replaygain plugin, we put the analysis backend into R128 mode. We can’t retroactively do this for files that have already been scanned. Maybe a naive conversion would be better than nothing?

cstoitner commented 6 years ago

I guess if the format can not be trivially converted, I would like to run the replaygain plugin again during the convert.

I use the convert plugin to create files for mobile devices. For a stopgap solution it would be nice to be able to run the replaygain plugin on files that are not part of the database.

sampsyo commented 6 years ago

Interesting! Re-running RG on the converted files seems somewhat hard to achieve—it would require some manner of interaction between the two (unrelated) plugins. Manually running the RG command on files that are not in the library is interesting too. A way to select non-library files for this kind of action will require some thoughtful design.

cstoitner commented 6 years ago

Alright, here is a different idea: I know which files will later get converted. The replaygain plugin could generate the data in both formats for all my flac files, write the replaygain tags to the files and store the R128 data only in the database. Then the convert plugin should write the R128 tags into the opus files when converting.

sampsyo commented 6 years ago

Sounds like a reasonable design at a high level! It would require some substantial complexity: we'll need an option to enable "dual" analysis (which should probably be optional because it will take twice as long) and a mechanism for storing the "inactive" data without writing it to the files—which will likely require inventing alternative names for each field. Seems complicated but doable if you want to give it a try!

cstoitner commented 6 years ago

Hey there, hope you had a nice weekend!

Unfortunately I don't think I have time to tackle this myself.

fabroce commented 6 years ago

Workaround : replaygain: backend: bs1770gain method: ebu r128: Opus FLAC overwrite: yes Opusenc can convert old raplaygains tags to r128 tags BUT it will not change other tags. The solution is to have r128 tags in FLAC files, then converted files will be ok. Problem left : Flac files have r128 and meaningless tags...

stale[bot] commented 4 years ago

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.