3 # Manipulate the time base of CMIF movies
8 # - resample at a fixed rate
9 # - divide the time codes by a speed factor (to make it go faster/slower)
10 # - drop frames that are less than n msec apart (to accommodate slow players)
15 # Vtime [-m msec] [-r msec] [-s speed] [infile [outfile]]
20 # -m n : drop frames closer than n msec (default 0)
21 # -r n : regenerate input time base n msec apart
22 # -s speed : speed change factor after other processing (default 1.0)
23 # infile : input file (default film.video)
24 # outfile : output file (default out.video)
28 sys
.path
.append('/ufs/guido/src/video')
41 # Main program -- mostly command line parsing
44 global speed
, mindelta
45 opts
, args
= getopt
.getopt(sys
.argv
[1:], 'm:r:s:')
48 mindelta
= string
.atoi(arg
)
50 regen
= string
.atoi(arg
)
52 speed
= float(eval(arg
))
54 args
.append('film.video')
56 args
.append('out.video')
58 sys
.stderr
.write('usage: Vtime [options] [infile [outfile]]\n')
60 sts
= process(args
[0], args
[1])
64 # Copy one file to another
66 def process(infilename
, outfilename
):
68 vin
= VFile
.BasicVinFile(infilename
)
70 sys
.stderr
.write(infilename
+ ': I/O error: ' + `msg`
+ '\n')
72 except VFile
.Error
, msg
:
73 sys
.stderr
.write(msg
+ '\n')
76 sys
.stderr
.write(infilename
+ ': EOF in video file\n')
80 vout
= VFile
.BasicVoutFile(outfilename
)
82 sys
.stderr
.write(outfilename
+ ': I/O error: ' + `msg`
+ '\n')
85 vout
.setinfo(vin
.getinfo())
96 tin
, data
, cdata
= vin
.getnextframe()
104 tout
= int(tout
/ speed
)
105 if tout
- told
< mindelta
:
108 vout
.writeframe(tout
, data
, cdata
)
115 # Don't forget to call the main program