Browse Source

make it cheaper to have the mpegtsmod loaded... We now do a quick

check to make sure there are TS packets, before scanning the first
2megs in an expensive iter loop to find out that there are none...
this makes things a lot faster...

[git-p4: depot-paths = "//depot/": change = 1126]
replace/b43bf02ddeddd088c0e6b94974ca1a46562eb3db
John-Mark Gurney 17 years ago
parent
commit
d8f81e4187
1 changed files with 20 additions and 0 deletions
  1. +20
    -0
      mpegtsmod.py

+ 20
- 0
mpegtsmod.py View File

@@ -344,7 +344,27 @@ class MultiMPEGTS(FSObject, StorageFolder):
if doupdate:
StorageFolder.doUpdate(self)

def findtsstream(fp, pktsz=188):
d = fp.read(200*pktsz)
i = 5
pos = 0
while i and pos < len(d) and pos != -1:
if d[pos] == 'G':
i -= 1
pos += pktsz
else:
i = 5
pos = d.find('G', pos + 1)

if i or pos == -1:
return False

return True

def detectmpegts(path, fobj):
if not findtsstream(fobj):
return None, None

f = mpegts.TSPStream(_LimitedFile(path, size= 2*1024*1024))
tvct = mpegts.GetTVCT(f)



Loading…
Cancel
Save