* mediagoblin.processing THUMB_/MEDIUM_ constants are now based on the ini settings
* Removed diaper patterns from audio and video sniffing
* Changed HTML5 video preload to 'metadata'
base_dir = string(default="%(here)s/user_dev/media/queue")
[media:medium]
+# Dimensions used when creating media display images.
max_width = integer(default=640)
max_height = integer(default=640)
[media:thumb]
+# Dimensions used when creating media thumbnails
+# This is unfortunately not implemented in the media
+# types yet. You can help!
+# TODO: Make plugins follow the media size settings
max_width = integer(default=180)
max_height = integer(default=180)
for media_type, manager in get_media_managers():
_log.info('Sniffing {0}'.format(media_type))
if manager['sniff_handler'](media_file, media=media):
+ _log.info('{0} accepts the file'.format(media_type))
return media_type, manager
+ else:
+ _log.debug('{0} did not accept the file'.format(media_type))
raise FileTypeNotSupported(
# TODO: Provide information on which file types are supported
import os
from mediagoblin import mg_globals as mgg
-from mediagoblin.processing import create_pub_filepath
+from mediagoblin.processing import create_pub_filepath, BadMediaFail
from mediagoblin.media_types.audio.transcoders import AudioTranscoder, \
AudioThumbnailer
_log = logging.getLogger(__name__)
def sniff_handler(media_file, **kw):
- transcoder = AudioTranscoder()
- try:
+ try:
+ transcoder = AudioTranscoder()
data = transcoder.discover(media_file.name)
+ except BadMediaFail:
+ _log.debug('Audio discovery raised BadMediaFail')
+ return False
- if data.is_audio == True and data.is_video == False:
- return True
- except:
- pass
+ if data.is_audio == True and data.is_video == False:
+ return True
return False
Takes a spectrogram and creates a thumbnail from it
'''
if not (type(thumb_size) == tuple and len(thumb_size) == 2):
- raise Exception('size argument should be a tuple(width, height)')
+ raise Exception('thumb_size argument should be a tuple(width, height)')
im = Image.open(src)
wadsworth_position = im_w * 0.3
start_x = max((
- wadsworth_position - (th_w / 2.0),
+ wadsworth_position - ((im_h * (th_w / th_h)) / 2.0),
0.0))
stop_x = start_x + (im_h * (th_w / th_h))
def sniff_handler(media_file, **kw):
transcoder = transcoders.VideoTranscoder()
- try:
- data = transcoder.discover(media_file.name)
+ data = transcoder.discover(media_file.name)
- _log.debug('Discovered: {0}'.format(data.__dict__))
+ _log.debug('Discovered: {0}'.format(data))
- if data.is_video == True:
- return True
- except:
- _log.error('Exception caught when trying to discover {0}'.format(
+ if not data:
+ _log.error('Could not discover {0}'.format(
kw.get('media')))
+ return False
+
+ if data['is_video'] == True:
+ return True
return False
self.loop.run()
- return self._discovered_data
+ if hasattr(self, '_discovered_data'):
+ return self._discovered_data.__dict__
+ else:
+ return None
def __on_discovered(self, data, is_media):
+ _log.debug('Discovered: {0}'.format(data))
if not is_media:
self.__stop()
raise Exception('Could not discover {0}'.format(self.source_path))
def __stop(self):
_log.debug(self.loop)
- # Stop executing the pipeline
- self.pipeline.set_state(gst.STATE_NULL)
+ if hasattr(self, 'pipeline'):
+ # Stop executing the pipeline
+ self.pipeline.set_state(gst.STATE_NULL)
# This kills the loop, mercifully
gobject.idle_add(self.__stop_mainloop)
_log = logging.getLogger(__name__)
-THUMB_SIZE = 180, 180
-MEDIUM_SIZE = 640, 640
+THUMB_SIZE = (mgg.global_config['media:thumb']['max_width'],
+ mgg.global_config['media:thumb']['max_height'])
+
+MEDIUM_SIZE = (mgg.global_config['media:medium']['max_width'],
+ mgg.global_config['media:medium']['max_height'])
def create_pub_filepath(entry, filename):
width="{{ media.media_data.video.width }}"
height="{{ media.media_data.video.height }}"
controls="controls"
- preload="auto"
+ preload="metadata"
data-setup="">
<source src="{{ request.app.public_store.file_url(
media.media_files['webm_640']) }}"