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

@@ -25,12 +25,15 @@ import os
import shutil
import tempfile
from mutagen.flac import FLAC
from morituri.common import common
from morituri.common import gstreamer as cgstreamer
from morituri.common import task as ctask
from morituri.extern.task import task, gstreamer
from morituri.program import sox
from morituri.program import flac
import logging
logger = logging.getLogger(__name__)
@@ -182,6 +185,48 @@ class SoxPeakTask(task.Task):
self.peak = sox.peak_level(self.track_path)
self.stop()
class FlacEncodeTask(task.Task):
description = 'Encoding to FLAC'
def __init__(self, track_path, track_out_path, what="track"):
self.track_path = track_path
self.track_out_path = track_out_path
self.new_path = None
self.description = 'Encoding %s to FLAC' % what
def start(self, runner):
task.Task.start(self, runner)
self.schedule(0.0, self._flac_encode)
def _flac_encode(self):
self.new_path = flac.encode(self.track_path, self.track_out_path)
self.stop()
# TODO: Wizzup: Do we really want this as 'Task'...?
# I only made it a task for now because that it's easier to integrate in
# program/cdparanoia.py - where morituri currently does the tagging.
# We should just move the tagging to a more sensible place.
class TaggingTask(task.Task):
description = 'Writing tags to FLAC'
def __init__(self, track_path, tags):
self.track_path = track_path
self.tags = tags
def start(self, runner):
task.Task.start(self, runner)
self.schedule(0.0, self._tag)
def _tag(self):
w = FLAC(self.track_path)
for k, v in self.tags.items():
w[k] = v
w.save()
self.stop()
class EncodeTask(ctask.GstPipelineTask):
"""
I am a task that encodes a .wav file.