diff options
author | vijeth-aradhya <vijthaaa@gmail.com> | 2017-08-22 13:30:13 +0530 |
---|---|---|
committer | vijeth-aradhya <vijthaaa@gmail.com> | 2017-08-22 13:34:53 +0530 |
commit | b89e12a23e55e0a1a4750e3107b114f27a0f0382 (patch) | |
tree | d5fc41e78d69d2c51af921815fa1986d594fdfa4 | |
parent | beb9121c0d0d86a575f3501e6070bf4f63956727 (diff) | |
download | mediagoblin-b89e12a23e55e0a1a4750e3107b114f27a0f0382.tar.lz mediagoblin-b89e12a23e55e0a1a4750e3107b114f27a0f0382.tar.xz mediagoblin-b89e12a23e55e0a1a4750e3107b114f27a0f0382.zip |
Add main_transcoding_progress to ProgressCallback
-rw-r--r-- | mediagoblin/media_types/video/transcoders.py | 6 | ||||
-rw-r--r-- | mediagoblin/processing/__init__.py | 6 |
2 files changed, 9 insertions, 3 deletions
diff --git a/mediagoblin/media_types/video/transcoders.py b/mediagoblin/media_types/video/transcoders.py index a2c8f431..dbe56d9e 100644 --- a/mediagoblin/media_types/video/transcoders.py +++ b/mediagoblin/media_types/video/transcoders.py @@ -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' diff --git a/mediagoblin/processing/__init__.py b/mediagoblin/processing/__init__.py index a9d5442b..2897b5e7 100644 --- a/mediagoblin/processing/__init__.py +++ b/mediagoblin/processing/__init__.py @@ -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() |