only extract audio, video if source has it

This commit is contained in:
j 2012-06-01 11:36:38 +02:00
parent 2ad9961d59
commit 46a80d8418

View file

@ -43,8 +43,11 @@ class Video(gst.Pipeline):
self.sbin.props.expose_all_streams = True self.sbin.props.expose_all_streams = True
self.add(self.src, self.sbin) self.add(self.src, self.sbin)
if self.video:
info = ox.avinfo(uri) info = ox.avinfo(uri)
self.audio = self.audio and info['audio'] != []
self.video = self.video and info['video'] != []
if self.video:
ratio = info['video'][0]['width'] / info['video'][0]['height'] ratio = info['video'][0]['width'] / info['video'][0]['height']
self.width = int(round(self.height * ratio)) self.width = int(round(self.height * ratio))
if self.width % 4: if self.width % 4: