Removed diaper patterns from audio/video sniffers, video preload set to 'metadata'
* 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'
This commit is contained in:
parent
10085b7739
commit
4f4f2531ad
@ -66,10 +66,15 @@ storage_class = string(default="mediagoblin.storage.filestorage:BasicFileStorage
|
||||
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)
|
||||
|
||||
|
@ -42,7 +42,10 @@ def sniff_media(media):
|
||||
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
|
||||
|
@ -19,7 +19,7 @@ import tempfile
|
||||
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
|
||||
@ -27,14 +27,15 @@ from mediagoblin.media_types.audio.transcoders import AudioTranscoder, \
|
||||
_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
|
||||
|
||||
|
@ -100,7 +100,7 @@ class AudioThumbnailer(object):
|
||||
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)
|
||||
|
||||
@ -110,7 +110,7 @@ class AudioThumbnailer(object):
|
||||
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))
|
||||
|
@ -30,16 +30,17 @@ _log.setLevel(logging.DEBUG)
|
||||
|
||||
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
|
||||
|
||||
|
@ -373,9 +373,13 @@ class VideoTranscoder:
|
||||
|
||||
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))
|
||||
@ -624,8 +628,9 @@ class VideoTranscoder:
|
||||
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)
|
||||
|
@ -27,8 +27,11 @@ from mediagoblin.media_types import get_media_manager
|
||||
|
||||
_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):
|
||||
|
@ -24,7 +24,7 @@
|
||||
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']) }}"
|
||||
|
Loading…
x
Reference in New Issue
Block a user