new avinfo format
This commit is contained in:
parent
28644ac0ae
commit
6aa9246b45
1 changed files with 29 additions and 14 deletions
|
@ -24,34 +24,49 @@ codec_list = {
|
||||||
|
|
||||||
class Info(dict):
|
class Info(dict):
|
||||||
def __init__(self, path):
|
def __init__(self, path):
|
||||||
|
self._stream_id = 0
|
||||||
|
self['video'] = []
|
||||||
|
self['audio'] = []
|
||||||
self['size'] = os.stat(path).st_size
|
self['size'] = os.stat(path).st_size
|
||||||
mainloop = gobject.MainLoop()
|
mainloop = gobject.MainLoop()
|
||||||
def discovered(d, is_media):
|
def discovered(d, is_media):
|
||||||
if is_media:
|
if is_media:
|
||||||
if d.is_video:
|
if d.is_video:
|
||||||
#self['video caps'] = d.videocaps
|
c = {}
|
||||||
#self['framerate (fps)'] = '%s:%s' % (d.videorate.num, d.videorate.denom)
|
c['width'] = d.videowidth
|
||||||
self['width'] = d.videowidth
|
c['height'] = d.videoheight
|
||||||
self['height'] = d.videoheight
|
self['duration'] = float(d.videolength)/gst.SECOND
|
||||||
self['duration'] = d.videolength/gst.MSECOND
|
c["framerate"] = "%d:%d" % (d.videorate.num, d.videorate.denom)
|
||||||
self['framerate'] = float(d.videorate)
|
|
||||||
s = d.videocaps[0]
|
s = d.videocaps[0]
|
||||||
|
par = gst.Fraction(1, 1)
|
||||||
if 'pixel-aspect-ratio' in s.keys():
|
if 'pixel-aspect-ratio' in s.keys():
|
||||||
self["pixel-aspect-ratio"] = "%d:%d" % (s['pixel-aspect-ratio'].num, s['pixel-aspect-ratio'].denom)
|
par = s['pixel-aspect-ratio']
|
||||||
|
c["pixel_aspect_ratio"] = "%s:%s" %(par.num, par.denom)
|
||||||
|
dar = gst.Fraction(d.videowidth * par.num, d.videoheight * par.denom)
|
||||||
|
if 'display-aspect-ratio' in s.keys():
|
||||||
|
dar = s['display-aspect-ratio']
|
||||||
|
c["display_aspect_ratio"] = "%s:%s" %(dar.num, dar.denom)
|
||||||
|
if 'video-codec' in d.tags:
|
||||||
|
c['codec'] = codec_list.get(d.tags['video-codec'], d.tags['video-codec'])
|
||||||
|
c['id'] = self._stream_id
|
||||||
|
self._stream_id += 1
|
||||||
|
self['video'].append(c)
|
||||||
if d.is_audio:
|
if d.is_audio:
|
||||||
|
c = {}
|
||||||
#self['audio caps'] = d.audiocaps
|
#self['audio caps'] = d.audiocaps
|
||||||
#self['audio format'] = d.audiofloat and 'floating-point' or 'integer'
|
#self['audio format'] = d.audiofloat and 'floating-point' or 'integer'
|
||||||
#self['sample width (bits)'] = d.audiowidth
|
#self['sample width (bits)'] = d.audiowidth
|
||||||
#self['sample depth (bits)'] = d.audiodepth
|
#self['sample depth (bits)'] = d.audiodepth
|
||||||
self['samplerate'] = d.audiorate
|
c['samplerate'] = d.audiorate
|
||||||
if 'duration' not in self:
|
if 'duration' not in self:
|
||||||
self['duration'] = d.audiolength/gst.MSECOND
|
self['duration'] = float(d.audiolength)/gst.SECOND
|
||||||
self['channels'] = d.audiochannels
|
c['channels'] = d.audiochannels
|
||||||
|
|
||||||
if 'video-codec' in d.tags:
|
if 'audio-codec' in d.tags:
|
||||||
self['video-codec'] = codec_list.get(d.tags['video-codec'], d.tags['video-codec'])
|
c['codec'] = codec_list.get(d.tags['audio-codec'], d.tags['audio-codec'])
|
||||||
if 'audio-codec' in d.tags:
|
c['id'] = self._stream_id
|
||||||
self['audio-codec'] = codec_list.get(d.tags['audio-codec'], d.tags['audio-codec'])
|
self._stream_id += 1
|
||||||
|
self['audio'].append(c)
|
||||||
mainloop.quit()
|
mainloop.quit()
|
||||||
|
|
||||||
d = discoverer.Discoverer(path)
|
d = discoverer.Discoverer(path)
|
||||||
|
|
Loading…
Reference in a new issue