Add gstreamer-less flac encoder and tagging (#121)

* Add encoding using Xiph.org 'flac' program.

This adds a FlacEncodeTask that encodes wave files to flac files.
This commit also replaces morituri's EncodeTask with FlacEncodeTask, however, in
morituri, EncodeTask also does the tagging.

FlacEncodeTask will not perform the tagging.
So we will need an extra task for the tagging - this will be added soon.

Meanwhile, do not merge this commit to master yet.

* Add tagging using mutagen.

Replace the gstreamer tagging code with mutagen tagging code.
getTagList is rewritten to return a dictionary of tags, which are then simply
passed to mutagen.

The way it is set up right now is not the best - I don't think it makes sense
for tagging to take place in program/cdparanoia.py ; but this is how the current
code did it.

I suggest that, when we rip out all the gstreamer code, we also move the tagging
to a more sensible place; and then also make the tagging not be an actual
'task.Task'.

* Add gstreamer-less CRC32 version

Only works on wave files at this point. Should not be a problem, I think.

* Use proper musicbrainz tags and ALBUM tag.

* Add mutagen to .travis.yml
This commit is contained in:
Merlijn Wajer
2017-02-02 21:50:47 +01:00
committed by JoeLametta
parent 4dc7a3cf77
commit 6ddb5d0114
8 changed files with 112 additions and 53 deletions

View File

@@ -490,12 +490,18 @@ class ReadVerifyTrackTask(task.MultiSeparateTask):
# here to avoid import gst eating our options
from morituri.common import encode
self.tasks.append(encode.EncodeTask(tmppath, tmpoutpath, profile,
taglist=taglist, what=what))
self.tasks.append(encode.FlacEncodeTask(tmppath, tmpoutpath))
# MerlijnWajer: XXX: We run the CRC32Task on the wav file, because it's
# in general stupid to run the CRC32 on the flac file since it already
# has --verify. We should just get rid of this CRC32 step.
# make sure our encoding is accurate
self.tasks.append(checksum.CRC32Task(tmpoutpath))
self.tasks.append(checksum.CRC32Task(tmppath))
self.tasks.append(encode.SoxPeakTask(tmppath))
# TODO: Move tagging outside of cdparanoia
self.tasks.append(encode.TaggingTask(tmpoutpath, taglist))
self.checksum = None
def stop(self):

18
morituri/program/flac.py Normal file
View File

@@ -0,0 +1,18 @@
from subprocess import check_call, CalledProcessError
import logging
logger = logging.getLogger(__name__)
def encode(infile, outfile):
"""
Encodes infile to outfile, with flac.
Uses '-f' because morituri already creates the file.
"""
try:
# TODO: Replace with Popen so that we can catch stderr and write it to
# logging
check_call(['flac', '--silent', '--verify', '-o', outfile,
'-f', infile])
except CalledProcessError:
logger.exception('flac failed')
raise