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")
|
base_dir = string(default="%(here)s/user_dev/media/queue")
|
||||||
|
|
||||||
[media:medium]
|
[media:medium]
|
||||||
|
# Dimensions used when creating media display images.
|
||||||
max_width = integer(default=640)
|
max_width = integer(default=640)
|
||||||
max_height = integer(default=640)
|
max_height = integer(default=640)
|
||||||
|
|
||||||
[media:thumb]
|
[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_width = integer(default=180)
|
||||||
max_height = integer(default=180)
|
max_height = integer(default=180)
|
||||||
|
|
||||||
|
@ -42,7 +42,10 @@ def sniff_media(media):
|
|||||||
for media_type, manager in get_media_managers():
|
for media_type, manager in get_media_managers():
|
||||||
_log.info('Sniffing {0}'.format(media_type))
|
_log.info('Sniffing {0}'.format(media_type))
|
||||||
if manager['sniff_handler'](media_file, media=media):
|
if manager['sniff_handler'](media_file, media=media):
|
||||||
|
_log.info('{0} accepts the file'.format(media_type))
|
||||||
return media_type, manager
|
return media_type, manager
|
||||||
|
else:
|
||||||
|
_log.debug('{0} did not accept the file'.format(media_type))
|
||||||
|
|
||||||
raise FileTypeNotSupported(
|
raise FileTypeNotSupported(
|
||||||
# TODO: Provide information on which file types are supported
|
# TODO: Provide information on which file types are supported
|
||||||
|
@ -19,7 +19,7 @@ import tempfile
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
from mediagoblin import mg_globals as mgg
|
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, \
|
from mediagoblin.media_types.audio.transcoders import AudioTranscoder, \
|
||||||
AudioThumbnailer
|
AudioThumbnailer
|
||||||
@ -27,14 +27,15 @@ from mediagoblin.media_types.audio.transcoders import AudioTranscoder, \
|
|||||||
_log = logging.getLogger(__name__)
|
_log = logging.getLogger(__name__)
|
||||||
|
|
||||||
def sniff_handler(media_file, **kw):
|
def sniff_handler(media_file, **kw):
|
||||||
transcoder = AudioTranscoder()
|
try:
|
||||||
try:
|
transcoder = AudioTranscoder()
|
||||||
data = transcoder.discover(media_file.name)
|
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:
|
if data.is_audio == True and data.is_video == False:
|
||||||
return True
|
return True
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ class AudioThumbnailer(object):
|
|||||||
Takes a spectrogram and creates a thumbnail from it
|
Takes a spectrogram and creates a thumbnail from it
|
||||||
'''
|
'''
|
||||||
if not (type(thumb_size) == tuple and len(thumb_size) == 2):
|
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)
|
im = Image.open(src)
|
||||||
|
|
||||||
@ -110,7 +110,7 @@ class AudioThumbnailer(object):
|
|||||||
wadsworth_position = im_w * 0.3
|
wadsworth_position = im_w * 0.3
|
||||||
|
|
||||||
start_x = max((
|
start_x = max((
|
||||||
wadsworth_position - (th_w / 2.0),
|
wadsworth_position - ((im_h * (th_w / th_h)) / 2.0),
|
||||||
0.0))
|
0.0))
|
||||||
|
|
||||||
stop_x = start_x + (im_h * (th_w / th_h))
|
stop_x = start_x + (im_h * (th_w / th_h))
|
||||||
|
@ -30,16 +30,17 @@ _log.setLevel(logging.DEBUG)
|
|||||||
|
|
||||||
def sniff_handler(media_file, **kw):
|
def sniff_handler(media_file, **kw):
|
||||||
transcoder = transcoders.VideoTranscoder()
|
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:
|
if not data:
|
||||||
return True
|
_log.error('Could not discover {0}'.format(
|
||||||
except:
|
|
||||||
_log.error('Exception caught when trying to discover {0}'.format(
|
|
||||||
kw.get('media')))
|
kw.get('media')))
|
||||||
|
return False
|
||||||
|
|
||||||
|
if data['is_video'] == True:
|
||||||
|
return True
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -373,9 +373,13 @@ class VideoTranscoder:
|
|||||||
|
|
||||||
self.loop.run()
|
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):
|
def __on_discovered(self, data, is_media):
|
||||||
|
_log.debug('Discovered: {0}'.format(data))
|
||||||
if not is_media:
|
if not is_media:
|
||||||
self.__stop()
|
self.__stop()
|
||||||
raise Exception('Could not discover {0}'.format(self.source_path))
|
raise Exception('Could not discover {0}'.format(self.source_path))
|
||||||
@ -624,8 +628,9 @@ class VideoTranscoder:
|
|||||||
def __stop(self):
|
def __stop(self):
|
||||||
_log.debug(self.loop)
|
_log.debug(self.loop)
|
||||||
|
|
||||||
# Stop executing the pipeline
|
if hasattr(self, 'pipeline'):
|
||||||
self.pipeline.set_state(gst.STATE_NULL)
|
# Stop executing the pipeline
|
||||||
|
self.pipeline.set_state(gst.STATE_NULL)
|
||||||
|
|
||||||
# This kills the loop, mercifully
|
# This kills the loop, mercifully
|
||||||
gobject.idle_add(self.__stop_mainloop)
|
gobject.idle_add(self.__stop_mainloop)
|
||||||
|
@ -27,8 +27,11 @@ from mediagoblin.media_types import get_media_manager
|
|||||||
|
|
||||||
_log = logging.getLogger(__name__)
|
_log = logging.getLogger(__name__)
|
||||||
|
|
||||||
THUMB_SIZE = 180, 180
|
THUMB_SIZE = (mgg.global_config['media:thumb']['max_width'],
|
||||||
MEDIUM_SIZE = 640, 640
|
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):
|
def create_pub_filepath(entry, filename):
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
width="{{ media.media_data.video.width }}"
|
width="{{ media.media_data.video.width }}"
|
||||||
height="{{ media.media_data.video.height }}"
|
height="{{ media.media_data.video.height }}"
|
||||||
controls="controls"
|
controls="controls"
|
||||||
preload="auto"
|
preload="metadata"
|
||||||
data-setup="">
|
data-setup="">
|
||||||
<source src="{{ request.app.public_store.file_url(
|
<source src="{{ request.app.public_store.file_url(
|
||||||
media.media_files['webm_640']) }}"
|
media.media_files['webm_640']) }}"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user