Browse Source

include the mpeg-ts helper programs, and comment on their location,

update the module to point to the current location...

document pydvdread...

[git-p4: depot-paths = "//depot/": change = 889]
v0.3
John-Mark Gurney 18 years ago
parent
commit
6715bb6857
4 changed files with 1694 additions and 4 deletions
  1. +5
    -2
      README
  2. +1619
    -0
      mpegts/mpegts.py
  3. +68
    -0
      mpegts/tssel.py
  4. +2
    -2
      mpegtsmod.py

+ 5
- 2
README View File

@@ -53,11 +53,14 @@ v0.3:
patches.
Look inside MPEG-TS for TVCT and/or PAT and if there is more
than one program, make it a container w/ the different
programs.
programs. Includes the program and MPEG-TS python module in
the mpegts directory.
Add support for multiple res elements and automatic transcoding
to either avi/xvid or mpeg2 using ffmpeg.
Look inside DVDs and handle titles and chapters. We can not yet
play the streams.
play the streams. This requires pydvdread which is included
in the directory pydvdread. It depends upon libdvdread and
requires a C compiler to build.
Empty dirs w/ no content would disappear, and cause a short
response to BrowseDirectChildren. The DSM-520 askes for one
more than displayed, and uses the existant of the extra item


+ 1619
- 0
mpegts/mpegts.py
File diff suppressed because it is too large
View File


+ 68
- 0
mpegts/tssel.py View File

@@ -0,0 +1,68 @@
#!/usr/bin/env python

import sys
sys.path.append('/Users/jgurney/p4/bktrau/info')

import itertools
import mpegts
import sys
import sets

def usage():
print >>sys.stderr, 'Usage: %s <file> <pmtpid> <pid> ...' % sys.argv[0]
sys.exit(1)

def genpats(pmt):
BASEPAT = map(None, "G@\x00\x10\x00\x00\xb0\r\x00\x00\xc1\x00\x00\x00\x01\xe0\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff")

patidx = 4 + 1 # TS header + pointer table
BASEPAT[patidx + 10] = chr(0xe0 | ((pmt >> 8) & 0x1f))
BASEPAT[patidx + 11] = chr(pmt & 0xff)
newcrc = mpegts.psip_calc_crc32(''.join(BASEPAT[patidx:patidx + 12]))
newcrc = map(lambda x, crc = newcrc: chr((crc >> (8 * (3 - x))) & 0xff), range(4))
BASEPAT[patidx + 12:patidx + 16] = newcrc

assert len(BASEPAT) == mpegts.TSPKTLEN

ret = []
old = ord(BASEPAT[3]) & 0xf0
for i in range(16): # continuity
BASEPAT[3] = chr(old | i)
ret.append(''.join(BASEPAT))

return ret

def producets(inp, pmtpid, *pids):
print `inp`, `pmtpid`, `pids`
pats = itertools.cycle(genpats(pmtpid))
# XXX - check if all pids are ints? in range?
pids = sets.Set(pids)

stream = mpegts.TSPStream(inp)
for i in stream:
frst = ord(i[1])
# Get first and error bits for testing.
pid = (frst & 0x1f) << 8 | ord(i[2])
if pid == pmtpid and (frst & 0xc0) == 0x40:
yield pats.next()
# XXX - we probably want to rewrite the PMT to only
# include the pids we are sending.
yield i
elif pid in pids:
yield i

def main():
if len(sys.argv) < 3:
usage()

pmtpid = int(sys.argv[2])
pids = map(int, sys.argv[3:])

inp = open(sys.argv[1])
out = sys.stdout

producer = producets(inp, pmtpid, *pids)
filter(lambda x: out.write(x), producer)

if __name__ == '__main__':
main()

+ 2
- 2
mpegtsmod.py View File

@@ -5,14 +5,14 @@
__version__ = '$Change$'
# $Id$

tsselpypath = '/Users/jgurney/p4/bktrau/info/tssel.py'
tsselpypath = 'mpegts/tssel.py'
default_audio_lang = 'eng'

import os
import sets

import sys
mpegtspath = '/Users/jgurney/p4/bktrau/info'
mpegtspath = 'mpegts'
if mpegtspath not in sys.path:
sys.path.append(mpegtspath)
import mpegts


Loading…
Cancel
Save