Added more format presets, updated documentation.

This commit is contained in:
Rowan Lewis 2013-09-14 09:35:25 +10:00
parent d2327d2dcf
commit 52d86f0e6a
2 changed files with 43 additions and 9 deletions

View file

@ -122,7 +122,8 @@ def should_transcode(item):
conversion (i.e., its bitrate is high or it has the wrong format).
"""
maxbr = config['convert']['max_bitrate'].get(int)
return item.format not in ['MP3', 'Opus', 'OGG'] or item.bitrate >= 1000 * maxbr
return item.format not in ['AAC', 'MP3', 'Opus', 'OGG', 'Windows Media'] or item.bitrate >= 1000 * maxbr
def convert_item(lib, dest_dir, keep_new, path_formats):
@ -238,6 +239,18 @@ class ConvertPlugin(BeetsPlugin):
u'threads': util.cpu_count(),
u'format': u'mp3',
u'formats': {
u'aac': {
u'command': u'ffmpeg -i $source -y -acodec libfaac -aq 100 $dest',
u'extension': u'm4a',
},
u'alac': {
u'command': u'ffmpeg -i $source -y -acodec alac $dest',
u'extension': u'm4a',
},
u'flac': {
u'command': u'ffmpeg -i $source -y -acodec flac $dest',
u'extension': u'flac',
},
u'mp3': {
u'command': u'ffmpeg -i $source -y -aq 2 $dest',
u'extension': u'mp3',
@ -250,6 +263,10 @@ class ConvertPlugin(BeetsPlugin):
u'command': u'ffmpeg -i $source -y -acodec libvorbis -vn -aq 2 $dest',
u'extension': u'ogg',
},
u'wma': {
u'command': u'ffmpeg -i $source -y -acodec wmav2 -vn $dest',
u'extension': u'wma',
},
},
u'max_bitrate': 500,
u'embed': True,

View file

@ -48,15 +48,15 @@ The plugin offers several configuration options, all of which live under the
or on the command line using the ``-d`` flag.
* ``embed`` indicates whether or not to embed album art in converted items.
Default: true.
* If you set ``max_bitrate``, all MP3 files with a higher bitrate will be
* If you set ``max_bitrate``, all lossy files with a higher bitrate will be
transcoded and those with a lower bitrate will simply be copied. Note that
this does not guarantee that all converted files will have a lower
bitrate---that depends on the encoder and its configuration. By default MP3s
will be copied without transcoding and all other formats will be converted.
* ``opts`` are the encoding options that are passed to ``ffmpeg``. Default:
"-aq 2". (Note that "-aq <num>" is equivalent to the LAME option "-V
<num>".) If you want to specify a bitrate, use "-ab <bitrate>". Refer to the
`FFmpeg`_ documentation for more details.
bitrate---that depends on the encoder and its configuration.
* ``format`` specify which format preset you would like to use. Default: mp3.
* ``formats`` lets you specify additional formats to convert to. Presets for
AAC, ALAC, FLAC, MP3, Opus, Vorbis and Windows Meda are provided, however
support may vary depending on your ffmpeg library. Each format is defined as
a command and a file extension.
* ``auto`` gives you the option to import transcoded versions of your files
automatically during the ``import`` command. With this option enabled, the
importer will transcode all non-MP3 files over the maximum bitrate before
@ -73,9 +73,26 @@ Here's an example configuration::
convert:
embed: false
format: aac
max_bitrate: 200
opts: -aq 4
dest: /home/user/MusicForPhone
threads: 4
paths:
default: $albumartist/$title
Here's how formats are configured::
convert:
format: mp3_high
formats:
mp3_high:
command: ffmpeg -i $source -y -aq 4 $dest
extension: mp3
The ``$source`` and ``$dest`` tokens are automatically replaced with the paths
to each file. Because ``$`` is used to delineate a field reference, you can
use ``$$`` to emit a dollars sign.
In this example ``-aq <num>`` is equivalent to the LAME option ``-V num``. If
you want to specify a bitrate, use ``-ab <bitrate>``. Refer to the `FFmpeg`_
documentation for more details.