Fixes for small bugs
There were some blocking issues in the code. They are small, but break tests and/or production. Fixed some of them.
This commit is contained in:
parent
0eeb2adad7
commit
4551a808be
@ -40,7 +40,7 @@ class VideoMediaManager(MediaManagerBase):
|
|||||||
video_res = video_config['available_resolutions']
|
video_res = video_config['available_resolutions']
|
||||||
video_res.remove(video_config['default_resolution'])
|
video_res.remove(video_config['default_resolution'])
|
||||||
video_res.insert(0, video_config['default_resolution'])
|
video_res.insert(0, video_config['default_resolution'])
|
||||||
video_res = map((lambda x: unicode('webm_' + str(x), 'utf-8')), video_res)
|
video_res = ['webm_{}'.format(x) for x in video_res]
|
||||||
return ([u'webm_video'] + video_res + [u'original'])
|
return ([u'webm_video'] + video_res + [u'original'])
|
||||||
|
|
||||||
|
|
||||||
|
@ -172,15 +172,17 @@ def main_task(entry_id, resolution, medium_size, **process_info):
|
|||||||
entry, manager = get_entry_and_processing_manager(entry_id)
|
entry, manager = get_entry_and_processing_manager(entry_id)
|
||||||
with CommonVideoProcessor(manager, entry) as processor:
|
with CommonVideoProcessor(manager, entry) as processor:
|
||||||
processor.common_setup(resolution)
|
processor.common_setup(resolution)
|
||||||
processor.transcode(medium_size=tuple(medium_size), vp8_quality=process_info['vp8_quality'],
|
processor.transcode(medium_size=tuple(medium_size),
|
||||||
vp8_threads=process_info['vp8_threads'], vorbis_quality=process_info['vorbis_quality'])
|
vp8_quality=process_info['vp8_quality'],
|
||||||
|
vp8_threads=process_info['vp8_threads'],
|
||||||
|
vorbis_quality=process_info['vorbis_quality'])
|
||||||
processor.generate_thumb(thumb_size=process_info['thumb_size'])
|
processor.generate_thumb(thumb_size=process_info['thumb_size'])
|
||||||
processor.store_orig_metadata()
|
processor.store_orig_metadata()
|
||||||
# Make state of entry as processed
|
# Make state of entry as processed
|
||||||
entry.state = u'processed'
|
entry.state = u'processed'
|
||||||
entry.save()
|
entry.save()
|
||||||
_log.info(u'MediaEntry ID {0} is processed (transcoded to default resolution'
|
_log.info(u'MediaEntry ID {0} is processed (transcoded to default'
|
||||||
'): {1}'.format(unicode(entry.id), unicode(medium_size)))
|
' resolution): {1}'.format(entry.id, medium_size))
|
||||||
_log.debug('MediaEntry processed')
|
_log.debug('MediaEntry processed')
|
||||||
|
|
||||||
|
|
||||||
@ -192,9 +194,12 @@ def complementary_task(entry_id, resolution, medium_size, **process_info):
|
|||||||
entry, manager = get_entry_and_processing_manager(entry_id)
|
entry, manager = get_entry_and_processing_manager(entry_id)
|
||||||
with CommonVideoProcessor(manager, entry) as processor:
|
with CommonVideoProcessor(manager, entry) as processor:
|
||||||
processor.common_setup(resolution)
|
processor.common_setup(resolution)
|
||||||
processor.transcode(medium_size=tuple(medium_size), vp8_quality=process_info['vp8_quality'],
|
processor.transcode(medium_size=tuple(medium_size),
|
||||||
vp8_threads=process_info['vp8_threads'], vorbis_quality=process_info['vorbis_quality'])
|
vp8_quality=process_info['vp8_quality'],
|
||||||
_log.info(u'MediaEntry ID {0} is transcoded to {1}'.format(unicode(entry.id), unicode(medium_size)))
|
vp8_threads=process_info['vp8_threads'],
|
||||||
|
vorbis_quality=process_info['vorbis_quality'])
|
||||||
|
_log.info(u'MediaEntry ID {0} is transcoded to {1}'.format(
|
||||||
|
entry.id, medium_size))
|
||||||
|
|
||||||
|
|
||||||
@celery.task()
|
@celery.task()
|
||||||
@ -336,7 +341,12 @@ class CommonVideoProcessor(MediaProcessor):
|
|||||||
|
|
||||||
else:
|
else:
|
||||||
_log.debug('Entered transcoder')
|
_log.debug('Entered transcoder')
|
||||||
|
video_config = (mgg.global_config['plugins']
|
||||||
|
['mediagoblin.media_types.video'])
|
||||||
|
num_res = len(video_config['available_resolutions'])
|
||||||
|
default_res = video_config['default_resolution']
|
||||||
self.transcoder.transcode(self.process_filename, tmp_dst,
|
self.transcoder.transcode(self.process_filename, tmp_dst,
|
||||||
|
default_res, num_res,
|
||||||
vp8_quality=vp8_quality,
|
vp8_quality=vp8_quality,
|
||||||
vp8_threads=vp8_threads,
|
vp8_threads=vp8_threads,
|
||||||
vorbis_quality=vorbis_quality,
|
vorbis_quality=vorbis_quality,
|
||||||
|
@ -158,7 +158,7 @@ class VideoTranscoder(object):
|
|||||||
self.progress_percentage = 0
|
self.progress_percentage = 0
|
||||||
self.loop = GLib.MainLoop()
|
self.loop = GLib.MainLoop()
|
||||||
|
|
||||||
def transcode(self, src, dst, **kwargs):
|
def transcode(self, src, dst, default_res, num_res, **kwargs):
|
||||||
'''
|
'''
|
||||||
Transcode a video file into a 'medium'-sized version.
|
Transcode a video file into a 'medium'-sized version.
|
||||||
'''
|
'''
|
||||||
@ -187,9 +187,8 @@ class VideoTranscoder(object):
|
|||||||
self._progress_callback = kwargs.get('progress_callback') or None
|
self._progress_callback = kwargs.get('progress_callback') or None
|
||||||
|
|
||||||
# Get number of resolutions available for the video
|
# Get number of resolutions available for the video
|
||||||
video_config = mgg.global_config['plugins']['mediagoblin.media_types.video']
|
self.num_of_resolutions = num_res
|
||||||
self.num_of_resolutions = len(video_config['available_resolutions'])
|
self.default_resolution = default_res
|
||||||
self.default_resolution = video_config['default_resolution']
|
|
||||||
|
|
||||||
if not type(self.destination_dimensions) == tuple:
|
if not type(self.destination_dimensions) == tuple:
|
||||||
raise Exception('dimensions must be tuple: (width, height)')
|
raise Exception('dimensions must be tuple: (width, height)')
|
||||||
|
@ -47,7 +47,10 @@ import os
|
|||||||
import pytest
|
import pytest
|
||||||
import webtest.forms
|
import webtest.forms
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
|
try:
|
||||||
import mock
|
import mock
|
||||||
|
except ImportError:
|
||||||
|
import unittest.mock as mock
|
||||||
|
|
||||||
import six.moves.urllib.parse as urlparse
|
import six.moves.urllib.parse as urlparse
|
||||||
|
|
||||||
|
@ -32,6 +32,7 @@ from mediagoblin.media_types.video.transcoders import (capture_thumb,
|
|||||||
VideoTranscoder)
|
VideoTranscoder)
|
||||||
from mediagoblin.media_types.video.util import ACCEPTED_RESOLUTIONS
|
from mediagoblin.media_types.video.util import ACCEPTED_RESOLUTIONS
|
||||||
from mediagoblin.media_types.tools import discover
|
from mediagoblin.media_types.tools import discover
|
||||||
|
from mediagoblin.tests.tools import get_app
|
||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
def create_data(suffix=None, make_audio=False):
|
def create_data(suffix=None, make_audio=False):
|
||||||
@ -115,6 +116,7 @@ def test_transcoder():
|
|||||||
transcoder = VideoTranscoder()
|
transcoder = VideoTranscoder()
|
||||||
transcoder.transcode(
|
transcoder.transcode(
|
||||||
video_name, result_name,
|
video_name, result_name,
|
||||||
|
'480p', 1,
|
||||||
vp8_quality=8,
|
vp8_quality=8,
|
||||||
vp8_threads=0, # autodetect
|
vp8_threads=0, # autodetect
|
||||||
vorbis_quality=0.3,
|
vorbis_quality=0.3,
|
||||||
@ -125,6 +127,7 @@ def test_transcoder():
|
|||||||
transcoder = VideoTranscoder()
|
transcoder = VideoTranscoder()
|
||||||
transcoder.transcode(
|
transcoder.transcode(
|
||||||
video_name, result_name,
|
video_name, result_name,
|
||||||
|
'480p', 1,
|
||||||
vp8_quality=8,
|
vp8_quality=8,
|
||||||
vp8_threads=0, # autodetect
|
vp8_threads=0, # autodetect
|
||||||
vorbis_quality=0.3,
|
vorbis_quality=0.3,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user