From ca83c75a9ef9c93672033b1c3d03591ca756220d Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Wed, 21 Jan 2009 17:24:45 +1100 Subject: [PATCH] dont try to detect anything if files is empty --- oxgst/info.py | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/oxgst/info.py b/oxgst/info.py index a1e0827..877d6f9 100644 --- a/oxgst/info.py +++ b/oxgst/info.py @@ -35,34 +35,34 @@ class Info: self.dbin = self.pipeline.get_by_name('dbin') 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.dbin.connect('new-decoded-pad', self.demux_pad_added) + self.bus.add_signal_watch() + self.watch_id = self.bus.connect("message", self.onBusMessage) - self.bus.add_signal_watch() - self.watch_id = self.bus.connect("message", self.onBusMessage) + self.pipeline.set_state(gst.STATE_PAUSED) + self.pipeline.get_state() - self.pipeline.set_state(gst.STATE_PAUSED) - self.pipeline.get_state() + #duration + 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 - 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 - - 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']) + 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): caps = sink.sink_pads().next().get_negotiated_caps()