conduit r1765 - in trunk/conduit: modules utils
- From: arosenfeld svn gnome org
- To: svn-commits-list gnome org
- Subject: conduit r1765 - in trunk/conduit: modules utils
- Date: Thu, 16 Oct 2008 03:04:06 +0000 (UTC)
Author: arosenfeld
Date: Thu Oct 16 03:04:06 2008
New Revision: 1765
URL: http://svn.gnome.org/viewvc/conduit?rev=1765&view=rev
Log:
- Improved GStreamer reliability in case of an error, both in a conversion and in the Media class.
Modified:
trunk/conduit/modules/AudioVideoConverterModule.py
trunk/conduit/utils/MediaFile.py
Modified: trunk/conduit/modules/AudioVideoConverterModule.py
==============================================================================
--- trunk/conduit/modules/AudioVideoConverterModule.py (original)
+++ trunk/conduit/modules/AudioVideoConverterModule.py Thu Oct 16 03:04:06 2008
@@ -221,8 +221,6 @@
class GStreamerConverter():
def _run_pipeline(self, **kwargs):
def converted(converter, success):
- if not success:
- raise Exception
self.success = success
event.set()
event = threading.Event()
@@ -302,11 +300,6 @@
log.debug("File %s is not video type: %s" % (video,mimetype))
return None
- kwargs['in_file'] = video.get_local_uri()
- kwargs['out_file'] = self._get_output_file(kwargs['in_file'], **kwargs)
- if os.path.exists(kwargs['out_file']):
- return Video.Video(kwargs['out_file'])
-
#Check if we need to convert the video
if kwargs.get('mimetype', None) == mimetype:
#Check if the video is smaller or equal then the required dimensions
@@ -314,7 +307,7 @@
width = kwargs.get('width', None)
height = kwargs.get('height', None)
if width or height:
- (video_width, video_height) = video.get_video_size()
+ (video_width, video_height) = video.get_video_size()
if (not width or video_width <= width) and \
(not height or video_height <= height):
log.debug("Video matches the required dimensions, not converting")
@@ -324,7 +317,13 @@
#so we dont convert it
log.debug("Video matches the mimetype, not converting")
return video
-
+
+ kwargs['in_file'] = video.get_local_uri()
+ kwargs['out_file'] = self._get_output_file(kwargs['in_file'], **kwargs)
+ if os.path.exists(kwargs['out_file']):
+ log.debug('Converted video already exists, using it')
+ return Video.Video(kwargs['out_file'])
+
if 'width' in kwargs and 'height' in kwargs:
(width, height) = video.get_video_size()
if not width and not height:
@@ -337,9 +336,13 @@
currentH=int(height)
)
log.debug("Scaling video to %swx%sh" % (kwargs['width'],kwargs['height']))
-
- gst_converter = GStreamerConverter()
- sucess = gst_converter.convert(**kwargs)
+
+ try:
+ gst_converter = GStreamerConverter()
+ sucess = gst_converter.convert(**kwargs)
+ except Exception, e:
+ log.debug("Error transcoding video: %s" % e)
+ return None
if not sucess:
log.debug("Error transcoding video\n")
Modified: trunk/conduit/utils/MediaFile.py
==============================================================================
--- trunk/conduit/utils/MediaFile.py (original)
+++ trunk/conduit/utils/MediaFile.py Thu Oct 16 03:04:06 2008
@@ -22,10 +22,7 @@
'''
event = threading.Event()
def discovered(discoverer, valid):
- if not valid:
- log.debug("Media file not valid")
- #FIXME: What exception should be raised here?
- raise Exception
+ self._valid = valid
event.set()
# FIXME: Using Discoverer for now, but we should switch to utils.GstMetadata
# when we get thumbnails working on it.
@@ -34,7 +31,11 @@
info.discover()
# Wait for discover to finish (which is async and emits discovered)
event.wait()
- tags = info.tags
+ if self._valid:
+ tags = info.tags
+ else:
+ log.debug("Media file not valid")
+ return {}
if info.is_video:
tags['width'] = info.videowidth
tags['height'] = info.videoheight
@@ -69,4 +70,4 @@
'''
if GST_AVAILABLE:
return self.gst_tags
- return None
+ return {}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]