3 # Copy a video file, fixing the line width to be a multiple of 4
8 # Vfix [infile [outfile]]
13 # infile : input file (default film.video)
14 # outfile : output file (default out.video)
19 sys
.path
.append('/ufs/guido/src/video')
23 # Main program -- mostly command line parsing
28 args
.append('film.video')
30 args
.append('out.video')
32 sys
.stderr
.write('usage: Vfix [infile [outfile]]\n')
34 sts
= process(args
[0], args
[1])
38 # Copy one file to another
40 def process(infilename
, outfilename
):
42 vin
= VFile
.BasicVinFile(infilename
)
44 sys
.stderr
.write(infilename
+ ': I/O error: ' + `msg`
+ '\n')
46 except VFile
.Error
, msg
:
47 sys
.stderr
.write(msg
+ '\n')
50 sys
.stderr
.write(infilename
+ ': EOF in video file\n')
54 vout
= VFile
.BasicVoutFile(outfilename
)
56 sys
.stderr
.write(outfilename
+ ': I/O error: ' + `msg`
+ '\n')
61 sys
.stderr
.write('Vfix: input not in grey format\n')
64 inwidth
, height
= vin
.getsize()
66 if (inwidth
/pf
)%4 == 0:
67 sys
.stderr
.write('Vfix: fix not necessary\n')
69 outwidth
= (inwidth
/pf
/4)*4*pf
70 print 'inwidth =', inwidth
, 'outwidth =', outwidth
71 vout
.setsize(outwidth
, height
)
76 t
, data
, cdata
= vin
.getnextframe()
78 sys
.stderr
.write('Frame ' + `n`
+ '...')
79 data
= imageop
.crop(data
, 1, inwidth
/pf
, height
/pf
, \
80 0, 0, outwidth
/pf
-1, height
/pf
-1)
81 vout
.writeframe(t
, data
, None)
82 sys
.stderr
.write('\n')
88 # Don't forget to call the main program