Convert using qaac (via wine)... possible?

Hi all.

I’m trying to use the convert plugin for encoding to aac/m4a and would like to use qaac to do it. Qaac is the best encoder for aac/m4a according to hydrogenaudio.

I have qaac installed using these excellent instructions. Using the command via plain old command line works fine, but I’m having trouble integrating it into my beets config file.

This is what I have currently:
command: wine ~/.wine/drive_c/qaac.exe -v256 -q2 $source $dest

This ends up failing however.

Hi! Folks on the forum might be able to help if you include a little more detail. In what way does it fail?

Not quiet sure, when I invoke it on an album like:
beet convert album:"album-name"

It just shows the following, basically:
convert: Encoding "path".flac failed. Cleaning up...

It doesn’t even try to actually encode, it’s pretty much instant. Encoding one track takes like 7 seconds normally.

Relevant convert settings are as follows (sorry, not sure how to get indenting to work on here):

convert:
dest: ‘~/Music/’
format: aac
formats:
aac:
command: wine ~/.wine/drive_c/qaac/qaac.exe -v256 -q2 $source $dest
extension: m4a

Can you try running in verbose mode (beet -vv)?

I did as suggested and Wine complained about it not being able to find the exe file, turns out you need to put in the full path.

However now it complains:

ERROR: Z:"path with file name".“extension”: File not found

The pathname it gives has escape slashes instead of forward slashes too.

This looks like a wine issue, it looks like it’s trying to put the file in a virtual Z drive?

EDIT: It was a qaac issue, once i put in the -d option for the output directory (-d $source) it actually encodes.

EDIT 2: It encodes but now creates weird recursive directory in it’s output.

It creates a file in the source directory named the same as the song name with the encoded extension (e.g. “tracknumber title.m4a”) which is actually a directory with the following subdirectory structure leading to the actual file.

/home/<username>/<music directory>/<format>/<album artist>/<album>/<file>

Which matches my normal $path setting but is not outputting at the “root” so to speak but recreating the whole structure within it.

I don’t know if this helps at all, but here’s the insecure way I’m currently using qaac with beet convert on Windows. I have a Python3 shim script that invokes ffmpeg which turns the input into WAV, then passes the WAV to qaac.

Maybe you can study how I’m invoking qaac and adapt it to your needs?

The relevant part of the script:

qaac64 --tvbr 82 --quality 30 --rate 44100 -o "''' + outfile + u'''" -'''

Part of the convert section of my config:

qaac:
        command: python c:\\apps\\cshim.py "$source" "$dest"
        extension: m4a

The script:

#shell=True is insecure.
import shutil
import subprocess
import sys
from pathlib import Path

MAX_CHANNELS = 3

infile = sys.argv[1]
outfile = sys.argv[2]

channels = 2

#quality=2 is default, higher values are slower to encode but higher quality
#I found a negligible time difference in quality={3, 30}
#might need higher tvbr to reach 160 kbps target
piped_cmd = u'''ffmpeg -i "''' + infile + u'''" -ac ''' + str(channels) + u''' -c:a pcm_s16le -f wav - | qaac64 --tvbr 82 --quality 30 --rate 44100 -o "''' + outfile + u'''" -'''
piped_cmd = piped_cmd

print(piped_cmd.encode('utf-8'))

#shell=True is insecure.
output=subprocess.check_output(piped_cmd, shell=True, encoding='utf-8')
print(output)