Skip to content

Commit

Permalink
[server] use aubio_decoder by default but make it selectable from set…
Browse files Browse the repository at this point in the history
…tings
  • Loading branch information
yomguy committed Mar 3, 2020
1 parent 0c710d1 commit 0286c7f
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 5 deletions.
1 change: 1 addition & 0 deletions app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,3 +270,4 @@
EMAIL_HOST = '134.158.33.163'
EMAIL_SUBJECT_PREFIX = '[TimeSide]'

TIMESIDE_DEFAULT_DECODER = 'aubio_decoder'
2 changes: 1 addition & 1 deletion timeside/plugins/analyzer/externals/aubio_pitch.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def name():
@staticmethod
@interfacedoc
def version():
return "0.4.7"
return "0.4.6"

@staticmethod
@interfacedoc
Expand Down
2 changes: 1 addition & 1 deletion timeside/plugins/decoder/aubio.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
""" decoder plugin based on aubio """

from timeside.core.decoder import Decoder, IDecoder, implements, interfacedoc
from timeside.plugins.decoder.utils import get_sha1
from timeside.plugins.decoder.utils import get_sha1, get_media_uri_info
import aubio
import mimetypes

Expand Down
1 change: 1 addition & 0 deletions timeside/plugins/decoder/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ def __init__(self, uri, start=0, duration=None, stack=False, sha1=None):
self._sha1 = sha1.encode('utf8')

self.uri_total_duration = get_media_uri_info(self.uri)['duration']
self.uri_duration = self.uri_total_duration

self.mimetype = None

Expand Down
15 changes: 12 additions & 3 deletions timeside/server/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ def get_processor_pids():
os.makedirs(RESULTS_ROOT)


DEFAULT_DECODER = getattr(settings, 'TIMESIDE_DEFAULT_DECODER', 'file_decoder')


class UUIDEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, UUID):
Expand Down Expand Up @@ -408,9 +411,9 @@ def get_audio_duration(self, force=False):
Return item audio duration
"""
if (force or not self.audio_duration) and self.source_file:
decoder = timeside.core.get_processor('file_decoder')(
decoder = timeside.core.get_processor(DEFAULT_DECODER)(
uri=self.get_uri())
self.audio_duration = decoder.uri_total_duration
self.audio_duration = decoder.uri_duration
super(Item, self).save()

def get_hash(self, force=False):
Expand Down Expand Up @@ -455,8 +458,14 @@ def run(self, experience):
uri = self.get_uri()

# decode audio source
decoder = timeside.plugins.decoder.file.FileDecoder(uri=uri,
# TODO: use get_processor
if DEFAULT_DECODER == 'aubio_decoder':
decoder = timeside.plugins.decoder.aubio.AubioDecoder(uri=uri,
sha1=self.sha1)
else:
decoder = timeside.plugins.decoder.file.FileDecoder(uri=uri,
sha1=self.sha1)

presets = {}
pipe = decoder
parent_analyzers = []
Expand Down

0 comments on commit 0286c7f

Please sign in to comment.