generalise cluster pruning routines
[sparrow.git] / convert_video.py
blobff6087c858d0e53c7ed163f38aedfc8f527bc211
1 #!/usr/bin/python
3 import os, sys, subprocess
5 SRC_DIR = "/home/douglas/sparrow/content/dv/"
6 DEST_DIR = "/home/douglas/sparrow/content/mjpeg/"
7 #for double frames
8 DF_DEST_DIR = "/home/douglas/sparrow/content/mjpeg_df/"
10 WIDTH = 800
11 HEIGHT = 600
12 CROP_RIGHT = 32
13 CROP_TOP = 24
14 PRE_CROP_RIGHT = 28
15 PRE_CROP_TOP = 21
17 def do_one(src, dest, df=False):
18 if df:
19 yadif_mode = 1
20 fps_list = ['-fps', '50', '-ofps', '50']
21 else:
22 yadif_mode = 0
23 fps_list = []
25 cmd = ["mencoder",
26 "-demuxer", "lavf",
27 src,
28 "-o", dest,
29 "-nosound",
30 "-ovc", "lavc",
31 "-lavcopts", "vcodec=mjpeg",
32 "-vf", ("yadif=%d,hqdn3d,scale=%d:%d,crop=%d:%d:%d:%d" %
33 (yadif_mode, WIDTH + CROP_RIGHT, HEIGHT + CROP_TOP,
34 WIDTH, HEIGHT, 0, CROP_TOP)),
35 ] + fps_list
37 subprocess.check_call(cmd)
39 if 0:
40 do_one(SRC_DIR + "sparrow-1-3-4-12-14145.dv",
41 DEST_DIR + "sparrow-1-3-4-12-14145-precrop.avi")
42 sys.exit()
44 def go(df=False):
45 if df:
46 destdir = DF_DEST_DIR
47 else:
48 destdir = DEST_DIR
49 for src in os.listdir(SRC_DIR):
50 dest = destdir + src + '.avi'
51 src = SRC_DIR + src
52 do_one(src, dest, df)
55 go()
59 #hqdn3d=4:3:6 [:6*3/4 == 4]