beetbox / beetbox/beets

convert: WavPack can be either lossless or lossy

Open
#2,789 1 comment 0 reactions 0 assignees View on GitHub
convert feature
Dominant language
Python
Stars
15.7k
Forks
2.1k
Avg merge
5d 4h
Merged PRs (30d)
35

Description

### Problem

When `convert: never_convert_lossy_files` is set to `yes`, all WavPack files are copied instead of converted regardless of their losslessness, because [currently `convert` treat `wv` files as lossy](https://github.com/beetbox/beets/blob/5f26ec6db9a852f623ea4dfeb2f99f7b43bb819b/beetsplug/convert.py#L46). It seems [current logic](https://github.com/beetbox/beets/blob/5f26ec6db9a852f623ea4dfeb2f99f7b43bb819b/beetsplug/convert.py#L104) is not sufficient to determine losslessness of WavPack files.

According to http://www.wavpack.com/wavpack_doc.html#wvunpack, `wvunpack -f9` can be used to obtain the encoding mode of a `wv` file. Can we handle `wv` files correctly by checking [`MODE_LOSSLESS`](https://github.com/dbry/WavPack/blob/76eab1023836f53501c0e3bc5d1702e62a3330c5/include/wavpack.h#L322) and [`MODE_HYBRID`](https://github.com/dbry/WavPack/blob/76eab1023836f53501c0e3bc5d1702e62a3330c5/include/wavpack.h#L323) of it?

### Setup

* OS: Ubuntu 16.04.3 LTS (on Windows)
* Python version: 3.6.4
* beets version: 1.4.6

My configuration (output of `beet config`) is:

```yaml
directory: ~/Music/Beets/Library
library: ~/Music/Beets/library.db
per_disc_numbering: yes

paths:
default: $album%aunique{}/%if{$disctotal-1,,$disc-}$track $title
comp: $album%aunique{}/%if{$disctotal-1,,$disc-}$track $title

ui:
color: yes

import:
write: yes
copy: yes
bell: yes

plugins: absubmit chroma convert embedart export fetchart fromfilename fuzzy info inline mbsubmit mbsync missing random web
absubmit:
auto: no
extractor: ~/bin/abzsubmit-0.1/streaming_extractor_music
chroma:
auto: no
acoustid:
apikey: REDACTED
convert:
auto: yes
never_convert_lossy_files: yes
format: alac
formats:
auto: ~/.config/beets/convert.py $source $dest
mp3: ffmpeg -i $source -y -vn -aq 1 $dest
wavpack:
command: wavpack -h $source -o $dest
extension: wv
aac:
command: ffmpeg -i $source -y -vn -acodec aac -aq 1 $dest
extension: m4a
alac:
command: ffmpeg -i $source -y -vn -acodec alac $dest
extension: m4a
flac: ffmpeg -i $source -y -vn -acodec flac $dest
opus: ffmpeg -i $source -y -vn -acodec libopus -ab 96k $dest
ogg: ffmpeg -i $source -y -vn -acodec libvorbis -aq 3 $dest
wma: ffmpeg -i $source -y -vn -acodec wmav2 -vn $dest
dest:
pretend: no
threads: 4
max_bitrate: 500
tmpdir:
quiet: no
embed: yes

paths: {}
no_convert: ''
copy_album_art: no
album_art_maxwidth: 0
embedart:
auto: yes
remove_art_file: yes
maxwidth: 0
compare_threshold: 0
ifempty: no
fetchart:
auto: yes
sources: coverart filesystem amazon albumart
store_source: yes
minwidth: 0
maxwidth: 0
enforce_ratio: no
cautious: no
cover_names:
- cover
- front
- art
- album
- folder
google_key: REDACTED
google_engine: 001442825323518660753:hrh5ch1gjzm
fanarttv_key: REDACTED
web:
host: 127.0.0.1
port: 8337
cors: ''
reverse_proxy: no
include_paths: no
mbsubmit:
format: $track. $title - $artist ($length)
threshold: medium
pathfields: {}
item_fields: {}
album_fields: {}
fuzzy:
prefix: '~'
threshold: 0.7
export:
default_format: json
json:
formatting:
ensure_ascii: no
indent: 4
separators: [',', ': ']
sort_keys: yes
missing:
count: no
total: no
album: no
```

Contributor guide

Open the contributing guide

Research direction

The conversion decision is in beetsplug/convert.py around lines 46 and 104; first inspect that logic and run wvunpack -f9 on representative WavPack files to observe the encoding mode. Done means never_convert_lossy_files distinguishes lossless and lossy WavPack files correctly instead of treating every .wv file the same.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.