Use audio icon when spectrogram fails. Add note to doc:media-types.
In addition to side-stepping spectrograms completely in Python 3 in 1038aea8, this commit adds some fallbacks that will help with potential issues in Python 2. Fixes Issue #5457 Signed-off-by: Ben Sturmfels <ben@sturm.com.au> Author: Jorge <mediagoblin@gybs.waa>
This commit is contained in:
parent
853147339b
commit
2b487fc16d
@ -133,10 +133,13 @@ To install these on Debianoid systems, run::
|
|||||||
|
|
||||||
If you're running Python 2, install ``scikits.audiolab`` for the spectrograms::
|
If you're running Python 2, install ``scikits.audiolab`` for the spectrograms::
|
||||||
|
|
||||||
./bin/pip install scikits.audiolab
|
.. code-block:: bash
|
||||||
|
|
||||||
Audio spectrograms are currently not available on Python 3, since scikits.audiolab
|
./bin/pip install numpy==1.9.1
|
||||||
does not provide Python 3 support.
|
./bin/pip install scikits.audiolab==0.10.2
|
||||||
|
|
||||||
|
For Python 3 ``scikits.audiolab`` has no package yet. Instead of the cool
|
||||||
|
specrogram image a static icon is used until we found a replacement. (#5467)
|
||||||
|
|
||||||
Add ``[[mediagoblin.media_types.audio]]`` under the ``[plugins]`` section in your
|
Add ``[[mediagoblin.media_types.audio]]`` under the ``[plugins]`` section in your
|
||||||
``mediagoblin.ini`` and restart MediaGoblin.
|
``mediagoblin.ini`` and restart MediaGoblin.
|
||||||
|
@ -148,9 +148,12 @@ class CommonAudioProcessor(MediaProcessor):
|
|||||||
_log.info('Creating OGG source for spectrogram')
|
_log.info('Creating OGG source for spectrogram')
|
||||||
self.transcoder.transcode(self.process_filename, wav_tmp,
|
self.transcoder.transcode(self.process_filename, wav_tmp,
|
||||||
mux_name='oggmux')
|
mux_name='oggmux')
|
||||||
|
|
||||||
spectrogram_tmp = os.path.join(self.workbench.dir,
|
spectrogram_tmp = os.path.join(self.workbench.dir,
|
||||||
self.name_builder.fill(
|
self.name_builder.fill(
|
||||||
'{basename}-spectrogram.jpg'))
|
'{basename}-spectrogram.jpg'))
|
||||||
|
|
||||||
|
try:
|
||||||
self.thumbnailer.spectrogram(
|
self.thumbnailer.spectrogram(
|
||||||
wav_tmp,
|
wav_tmp,
|
||||||
spectrogram_tmp,
|
spectrogram_tmp,
|
||||||
@ -158,13 +161,22 @@ class CommonAudioProcessor(MediaProcessor):
|
|||||||
fft_size=fft_size)
|
fft_size=fft_size)
|
||||||
|
|
||||||
_log.debug('Saving spectrogram...')
|
_log.debug('Saving spectrogram...')
|
||||||
store_public(self.entry, 'spectrogram', spectrogram_tmp,
|
store_public(self.entry, 'spectrogram', thumbnail,
|
||||||
self.name_builder.fill('{basename}.spectrogram.jpg'))
|
self.name_builder.fill('{basename}.spectrogram.jpg'))
|
||||||
|
|
||||||
file_metadata = {'max_width': max_width,
|
file_metadata = {'max_width': max_width,
|
||||||
'fft_size': fft_size}
|
'fft_size': fft_size}
|
||||||
self.entry.set_file_metadata('spectrogram', **file_metadata)
|
self.entry.set_file_metadata('spectrogram', **file_metadata)
|
||||||
|
|
||||||
|
except IndexError:
|
||||||
|
_log.warn(
|
||||||
|
'Your version of Numpy is too new to create the waveform thumbnail (#5457). '
|
||||||
|
"Try\n\t./bin/pip install numpy==1.9.1\n\t./bin/pip install scikits.audiolab==0.10.2")
|
||||||
|
|
||||||
|
except Exception as exc:
|
||||||
|
_log.warn('Failed to create spectrogram: '
|
||||||
|
+ '{0}'.exc)
|
||||||
|
|
||||||
def generate_thumb(self, size=None):
|
def generate_thumb(self, size=None):
|
||||||
if not size:
|
if not size:
|
||||||
max_width = mgg.global_config['media:thumb']['max_width']
|
max_width = mgg.global_config['media:thumb']['max_width']
|
||||||
@ -178,6 +190,7 @@ class CommonAudioProcessor(MediaProcessor):
|
|||||||
'{basename}-thumbnail.jpg'))
|
'{basename}-thumbnail.jpg'))
|
||||||
|
|
||||||
# We need the spectrogram to create a thumbnail
|
# We need the spectrogram to create a thumbnail
|
||||||
|
try:
|
||||||
spectrogram = self.entry.media_files.get('spectrogram')
|
spectrogram = self.entry.media_files.get('spectrogram')
|
||||||
if not spectrogram:
|
if not spectrogram:
|
||||||
_log.info('No spectrogram found, we will create one.')
|
_log.info('No spectrogram found, we will create one.')
|
||||||
@ -186,6 +199,10 @@ class CommonAudioProcessor(MediaProcessor):
|
|||||||
|
|
||||||
spectrogram_filepath = mgg.public_store.get_local_path(spectrogram)
|
spectrogram_filepath = mgg.public_store.get_local_path(spectrogram)
|
||||||
|
|
||||||
|
except:
|
||||||
|
_log.warn('Failed to create spectrogram, using default audio image instead.')
|
||||||
|
spectrogram_filepath = 'mediagoblin/static/images/media_thumbs/audio.png'
|
||||||
|
|
||||||
self.thumbnailer.thumbnail_spectrogram(
|
self.thumbnailer.thumbnail_spectrogram(
|
||||||
spectrogram_filepath,
|
spectrogram_filepath,
|
||||||
thumb_tmp,
|
thumb_tmp,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user