dont try to detect anything if files is empty

This commit is contained in:
j 2009-01-21 17:24:45 +11:00
parent 9f489d306b
commit ca83c75a9e

View file

@ -35,34 +35,34 @@ class Info:
self.dbin = self.pipeline.get_by_name('dbin') self.dbin = self.pipeline.get_by_name('dbin')
self.metadata['size'] = os.stat(videofile).st_size self.metadata['size'] = os.stat(videofile).st_size
if self.metadata['size'] != 0:
self.bus = self.pipeline.get_bus()
self.dbin.connect('new-decoded-pad', self.demux_pad_added)
self.bus = self.pipeline.get_bus() self.bus.add_signal_watch()
self.dbin.connect('new-decoded-pad', self.demux_pad_added) self.watch_id = self.bus.connect("message", self.onBusMessage)
self.bus.add_signal_watch() self.pipeline.set_state(gst.STATE_PAUSED)
self.watch_id = self.bus.connect("message", self.onBusMessage) self.pipeline.get_state()
self.pipeline.set_state(gst.STATE_PAUSED) #duration
self.pipeline.get_state() pads = None
if self.video:
pads = self.video.sink_pads()
elif self.audio:
pads = self.audio.sink_pads()
if pads:
q = gst.query_new_duration(gst.FORMAT_TIME)
for pad in pads:
if pad.get_peer() and pad.get_peer().query(q):
format, self.duration = q.parse_duration()
self.metadata["duration"] = self.duration/gst.MSECOND
#duration self.mainloop.run()
pads = None if 'video-codec' in self.tags:
if self.video: self.metadata['video-codec'] = codec_list.get(self.tags['video-codec'], self.tags['video-codec'])
pads = self.video.sink_pads() if 'audio-codec' in self.tags:
elif self.audio: self.metadata['audio-codec'] = codec_list.get(self.tags['audio-codec'], self.tags['audio-codec'])
pads = self.audio.sink_pads()
if pads:
q = gst.query_new_duration(gst.FORMAT_TIME)
for pad in pads:
if pad.get_peer() and pad.get_peer().query(q):
format, self.duration = q.parse_duration()
self.metadata["duration"] = self.duration/gst.MSECOND
self.mainloop.run()
if 'video-codec' in self.tags:
self.metadata['video-codec'] = codec_list.get(self.tags['video-codec'], self.tags['video-codec'])
if 'audio-codec' in self.tags:
self.metadata['audio-codec'] = codec_list.get(self.tags['audio-codec'], self.tags['audio-codec'])
def get_audio_info_cb(self, sink, buffer, pad): def get_audio_info_cb(self, sink, buffer, pad):
caps = sink.sink_pads().next().get_negotiated_caps() caps = sink.sink_pads().next().get_negotiated_caps()