Ticket #460: issue_460.patch

File issue_460.patch, 2.9 KB (added by Boris Bobrov, 10 years ago)
  • mediagoblin/media_types/video/processing.py

    From 4b17a8b59291c70231a2ff237ae47d36c12affa0 Mon Sep 17 00:00:00 2001
    From: Boris Bobrov <breton@cynicmansion.ru>
    Date: Sat, 7 Mar 2015 13:30:43 +0300
    Subject: [PATCH] Prevent exception on transcoding failure
    
    Fix an unhandled exception when video fails to transcode for some
    reason
    ---
     mediagoblin/media_types/video/processing.py  |   22 ++++++++++++----------
     mediagoblin/media_types/video/transcoders.py |    1 +
     2 files changed, 13 insertions(+), 10 deletions(-)
    
    diff --git a/mediagoblin/media_types/video/processing.py b/mediagoblin/media_types/video/processing.py
    index bf19522..6c50642 100644
    a b class CommonVideoProcessor(MediaProcessor):  
    273273                                      vorbis_quality=vorbis_quality,
    274274                                      progress_callback=progress_callback,
    275275                                      dimensions=tuple(medium_size))
    276             video_info = self.transcoder.dst_data.get_video_streams()[0]
    277             dst_dimensions = (video_info.get_width(), video_info.get_height())
    278             self._keep_best()
     276            if self.transcoder.dst_data:
     277                video_info = self.transcoder.dst_data.get_video_streams()[0]
     278                dst_dimensions = (video_info.get_width(),
     279                                  video_info.get_height())
     280                self._keep_best()
    279281
    280             # Push transcoded video to public storage
    281             _log.debug('Saving medium...')
    282             store_public(self.entry, 'webm_video', tmp_dst,
    283                          self.name_builder.fill('{basename}.medium.webm'))
    284             _log.debug('Saved medium')
     282                # Push transcoded video to public storage
     283                _log.debug('Saving medium...')
     284                store_public(self.entry, 'webm_video', tmp_dst,
     285                             self.name_builder.fill('{basename}.medium.webm'))
     286                _log.debug('Saved medium')
    285287
    286             self.entry.set_file_metadata('webm_video', **file_metadata)
     288                self.entry.set_file_metadata('webm_video', **file_metadata)
    287289
    288             self.did_transcode = True
     290                self.did_transcode = True
    289291
    290292        # Save the width and height of the transcoded video
    291293        self.entry.media_data_init(
  • mediagoblin/media_types/video/transcoders.py

    diff --git a/mediagoblin/media_types/video/transcoders.py b/mediagoblin/media_types/video/transcoders.py
    index 3c060fd..ba469af 100644
    a b class VideoTranscoder(object):  
    358358                    _log.info('{percent}% done...'.format(percent=percent))
    359359        elif message.type == Gst.MessageType.ERROR:
    360360            _log.error('Got error: {0}'.format(message.parse_error()))
     361            self.dst_data = None
    361362            self.__stop()
    362363
    363364    def __stop(self):