2 function: Ogg ReSerializer
3 last mod: $Id: reserializer.py
5 This is a useful tool for changing the serial number of an Ogg stream.
6 Why is it useful? Because you can't chain two logical streams together
7 in the same physical stream which have the same serial numbers.
14 infilename
= raw_input('Input File: ')
15 outfilename
= raw_input('Output File: ')
17 inf
=open(infilename
, 'r')
18 otf
=open(outfilename
, 'w')
20 syncin
=ogg2
.OggSyncState()
21 syncout
=ogg2
.OggSyncState()
25 while 1: # While there's data to input
26 if syncin
.input(inf
) == 0 : break
27 while 1: # While there are pages to output
28 page
= syncin
.pageout()
31 serials
[page
.serialno
] = int(random
.random()*2147483647)
32 print 'ReSerializing stream %d to %d' % (page
.serialno
,
33 serials
[page
.serialno
])
34 if serials
.has_key(page
.serialno
) :
35 page
.serialno
= serials
[page
.serialno
]
38 if syncout
.output(otf
) == 0 : break
40 print 'Headless stream %d found, skipping' % page
.serialno