beetbox / beets

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

Is there a way to get VBR's to be imported as V0/2, rather than beets giving the average bit rate upon import? #3094

Closed bridgestrawdog closed 4 years ago

bridgestrawdog commented 5 years ago

It would be great it beets could tag my MP3 files as V0 (which is the format the majority of my music is in). Rather than 00-01 - Tallahassee (250kbps) I would love it if I could get 00-01 - Tallahassee (V0) instead.

My configuration (output of beet config) is:

directory: F:\Music
library: C:\Users\punished_snake\Musiclibrary.db
#This sets where I want my music stored (directory), and where the database file is located (library).

plugins: the fetchart embedart scrub lastgenre web fromfilename lyrics ftintitle
#zero
#These are the plugins that I use to maintain my metadata. "the" is able to recognize prefixes in artist names, and move them to the end of the string. "fetchart" and "embedart" are relatively self-explanatory. "scrub" clears all metadata before applying the new, clean metadata.

import:
    copy: yes
    write: yes

#When I use the "import" command, I want beets to move the files, not copy them. This is because I run beets in my downloads folder, where I download all of my music to, and want those files to be moved neatly into my music drive.

ui:
    color: no
#Beets color-codes its information in the command prompt. I found this somewhat ugly to look at, so I turned it off.

per_disc_numbering: yes
#By default, if there are two discs in an album, beets will ignore the fact that there's two discs. If there's 10 songs in disc 1, and 10 in disc 2, the first track of disc 2 is numbered as 11. I want my discs tagged separately, so track 1 of disc 2 starts over as track 1.

threaded: yes    
#Self-explanatory

paths:
    default: %the{$albumartist}/$original_year-$original_month-$original_day - $album%aunique{} [%upper{$albumtype}] (%upper{$format})/$disc-$track - $title ($bitrate)
    singleton: "#Non-Album/$artist/$title"
    comp: "#Compilations/%the{$albumartist}/$original_year-$original_month - $album%aunique{} [%upper{$albumtype}] (%upper{$format})/$disc-$track - $title ($bitrate)"

#This is perhaps the hardest to understand part of beets, even for me. I want a complicated folder structure for my library. This is where beets really shines; you can make it sort music however you want. Let me explain each part of this configuration in full.

#"%the{$albumartist}/": This is the parent directory of everything. It is simply the "album artist" tag, argumented with the "the" plugin to move articles to the end of the string. So, "The Black Keys" becomes "Black Keys, The". This assures that my music library stays in alphabetical order.

#"$original_year-$original_month-$original_day - $album%aunique{} [%upper{$albumtype}] (%upper{$format})": Looking at it, this is a huge mess. This is the next sub-folder, under the album artist folder. Basically, it puts the date first (so my releases are in chronological order), adds a dash, puts the album's name, adds the album type (EP, Single, or Album) in all capital letters in parentheses, and then adds the file format of the album (MP3 or FLAC) in all caps in brackets. It looks complicated, but the result is clean and simple.

#"$disc-$track - $title ($bitrate)": This is the actual music file, under the release folder. It's fairly simple. It puts the disc and track, then a dash, then the title, and then the bitrate of the file in parentheses.

#All of these extremely complicated arguments have a very nice and clean result. For example, the path to the song "Bodak Yellow (Money Moves)" by Cardi B is as follows:

#G:\Music\Cardi B\2017-06-16 - Bodak Yellow (Money Moves) [SINGLE] (MP3)\01-01 - Bodak Yellow (Money Moves) (320kbps).mp3

fetchart:
    maxwidth: 500
    enforce_ratio: yes
    sources: filesystem itunes amazon albumart coverart
#This is the arguments for the fetchart plugin. The minimum width of the downloaded album art is 400 pixels. The maximum deviation from perfectly square the photo can have is 10px, either vertically or horizontally. The sources are a list of where beets will look for album art, starting at the left and going to the right. I put filesystem first so beets checks my files for a cover first, and only goes onto the internet to find one if there isn't one already.

embedart:
    auto: yes
#Embed art is great, but it slows down the import process a lot. I run the command when I want to and have a lot of time to spare. I do not want it to automatically run when I import my music.

zero:
    fields: comments

lyrics:
    auto: yes
    force: yes
    google_API_key: AIzaSyCpdq2d27dChniU1Wgi0GrzdfmHjnTEhYs
    sources: google lyricwiki lyrics.com musixmatch 

ftintitle:
     auto: yes

#zero:
     #auto: yes

I have zero commented out otherwise I get the dreaded 'zero: cannot zero in "as-is" mode' error. I updated zero.py form the fix at # #2329 but it didn't seem to work. But obviously my first query is more important.

If anybody knows if this can be done, please let me know. I did a search on the matter but most things I found were from 2003/4 so I couldn't find anything useful.

sampsyo commented 5 years ago

Hi! Have you seen https://github.com/beetbox/beets/issues/116, wherein there's an ongoing effort to detect LAME presets?

bridgestrawdog commented 5 years ago

Hey @sampsyo , I had in fact seen that but not had time to look over it fully? Is there a plugin release for it yet?

RollingStar commented 5 years ago

If you can detect V0/V2/etc in Python, you should be able to at least rename folder / file paths to have V0 or whatever in the filename. Look at the inline plugin. https://beets.readthedocs.io/en/latest/plugins/inline.html

As for "tagging", as in "file tags", I don't know if you can. The beets database can store custom tags but I don't know about writing to file tags.

I use inline in my (now outdated) config, if you want to see it in action.

https://github.com/RollingStar/dial-beets/blob/master/config.yaml

edit: I found this online.

[$mybitrate]

album_fields: 
    mybitrate: |
        total = 0
        for item in items:
            total += item.bitrate
        abr = total / len(items) / 1000  
        if abr > 480:
            return 'FLAC'
        elif abr < 480 and abr >= 320:
            return '320'
        elif abr < 320 and abr >= 220:
            return 'V0'  
        elif abr < 215 and abr >= 170 and abr != 192:
            return 'V2'
        elif abr == 192:
            return '192'
        elif abr < 170:
            return abr
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.

0011FF commented 11 months ago

This is a solution I came up with for 1.6.0


item_fields:
    vbr_preset: |
        if format.lower() != 'mp3':
            return
        import os
        from pymediainfo import MediaInfo
        media_info = MediaInfo.parse(path.decode())
        if media_info.tracks[1].bit_rate_mode == None:
            return
        if media_info.tracks[1].bit_rate_mode.lower() not in ['variable','vbr']:
            return str(round(bitrate/1000)) + 'k'
        es = media_info.tracks[1].encoding_settings
        es_i = es.split().index('-V')+1
        quality = es.split()[es_i]
        return 'V' + str(quality)