Add main_transcoding_progress to ProgressCallback
This commit is contained in:
parent
beb9121c0d
commit
b89e12a23e
@ -190,6 +190,7 @@ class VideoTranscoder(object):
|
||||
# Get number of resolutions available for the video
|
||||
video_config = mgg.global_config['plugins']['mediagoblin.media_types.video']
|
||||
self.num_of_resolutions = len(video_config['available_resolutions'])
|
||||
self.default_resolution = video_config['default_resolution']
|
||||
|
||||
if not type(self.destination_dimensions) == tuple:
|
||||
raise Exception('dimensions must be tuple: (width, height)')
|
||||
@ -368,7 +369,10 @@ class VideoTranscoder(object):
|
||||
percent_increment = percent - self.progress_percentage
|
||||
self.progress_percentage = percent
|
||||
if self._progress_callback:
|
||||
self._progress_callback(percent_increment/self.num_of_resolutions)
|
||||
if ACCEPTED_RESOLUTIONS[self.default_resolution] == self.destination_dimensions:
|
||||
self._progress_callback(percent_increment/self.num_of_resolutions, percent)
|
||||
else:
|
||||
self._progress_callback(percent_increment/self.num_of_resolutions)
|
||||
_log.info('{percent}% of {dest} resolution done..'
|
||||
'.'.format(percent=percent, dest=self.destination_dimensions))
|
||||
_log.info('{0:.2f}% of all resolutions done'
|
||||
|
@ -39,12 +39,14 @@ class ProgressCallback(object):
|
||||
def __init__(self, entry):
|
||||
self.entry = entry
|
||||
|
||||
def __call__(self, progress):
|
||||
def __call__(self, progress, default_quality_progress=None):
|
||||
if progress:
|
||||
if 100 - (self.entry.transcoding_progress + progress) < 0.01:
|
||||
self.entry.transcoding_progress = 100
|
||||
else:
|
||||
self.entry.transcoding_progress += progress
|
||||
self.entry.transcoding_progress += round(progress, 2)
|
||||
if default_quality_progress:
|
||||
self.entry.main_transcoding_progress = default_quality_progress
|
||||
self.entry.save()
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user