Small changes to fixing transcode percentage
authorvijeth-aradhya <vijthaaa@gmail.com>
Fri, 11 Aug 2017 14:10:41 +0000 (19:40 +0530)
committervijeth-aradhya <vijthaaa@gmail.com>
Fri, 11 Aug 2017 14:10:41 +0000 (19:40 +0530)
Related to #6

mediagoblin/media_types/video/processing.py
mediagoblin/media_types/video/transcoders.py

index e343930bf9d60dfe9737bbc93a978269078d0784..114c505714217336bfb6cf5028b9a6607c506690 100644 (file)
@@ -336,13 +336,12 @@ class CommonVideoProcessor(MediaProcessor):
 
         else:
             _log.debug('Entered transcoder')
-            self.transcoder.transcode(self.process_filename, tmp_dst,
+            self.transcoder.transcode(self.process_filename, tmp_dst, self.entry,
                                       vp8_quality=vp8_quality,
                                       vp8_threads=vp8_threads,
                                       vorbis_quality=vorbis_quality,
                                       progress_callback=progress_callback,
-                                      dimensions=tuple(medium_size),
-                                      media_entry=self.entry)
+                                      dimensions=tuple(medium_size))
             if self.transcoder.dst_data:
                 # Push transcoded video to public storage
                 _log.debug('Saving medium...')
index d94bf59fffd7e164b65cbe8145d83b70a2626ca9..a2c8f4316e382feac64dcc0716d633cfea321ec7 100644 (file)
@@ -155,18 +155,16 @@ class VideoTranscoder(object):
     '''
     def __init__(self):
         _log.info('Initializing VideoTranscoder...')
-        self.progress_percentage = None
+        self.progress_percentage = 0
         self.loop = GLib.MainLoop()
 
-    def transcode(self, src, dst, **kwargs):
+    def transcode(self, src, dst, entry, **kwargs):
         '''
         Transcode a video file into a 'medium'-sized version.
         '''
         self.source_path = src
         self.destination_path = dst
-
-        # Get media entry
-        self.entry = kwargs.get('media_entry') or None
+        self.entry = entry
 
         # vp8enc options
         self.destination_dimensions = kwargs.get('dimensions', (640, 640))
@@ -190,9 +188,8 @@ class VideoTranscoder(object):
         self._progress_callback = kwargs.get('progress_callback') or None
 
         # Get number of resolutions available for the video
-        video_config = mgg.global_config['plugins']['mediagoblin.media_types.video']     
+        video_config = mgg.global_config['plugins']['mediagoblin.media_types.video']
         self.num_of_resolutions = len(video_config['available_resolutions'])
-        self.progress_percentage = 0
 
         if not type(self.destination_dimensions) == tuple:
             raise Exception('dimensions must be tuple: (width, height)')
@@ -364,6 +361,8 @@ class VideoTranscoder(object):
                 # Update progress state if it has changed
                 (success, percent) = structure.get_int('percent')
                 if self.progress_percentage != percent and success:
+                    # FIXME: the code below is a workaround for structure.get_int('percent')
+                    # returning 0 when the transcoding gets over (100%)
                     if self.progress_percentage > percent and percent == 0:
                         percent = 100
                     percent_increment = percent - self.progress_percentage