OSDN Git Service

implement encode tester.
[rec10/rec10-git.git] / rec10 / trunk / src / auto_test.py
1 #!/usr/bin/python
2 # coding: UTF-8
3 # Rec10 TS Recording Tools
4 # Copyright (C) 2009-2010 Yukikaze
5 import os
6 import os.path
7 import time
8 import optparse
9 import sys
10
11 import configreader
12 import chdb
13 import tv2mp4
14 import tv2ts
15 def test_all_ch_encode(option,stime):
16     chl=chdb.getall()
17     print chl
18     path= configreader.getpath("test")
19     tpath=os.path.join(path, "encode_test")
20     if not os.path.exists(tpath):
21         os.mkdir(tpath)
22     dnowt=datetime.datetime.now().strftime("%Y-%m-%d_%H:%M:%S")+"("+option+")"
23     tpatht=os.path.join(tpath,dnowt)
24     if not os.path.exists(tpatht):
25         os.mkdir(tpatht)
26     if len(chl)>0:
27         for t in chl:
28             print t
29             pathname=os.path.join(tpatht,t['chtxt'])
30             print pathname
31             tv2ts.tv2ts(pathname+".ts",t['ch'],t['csch'], stime)
32             tv2mp4.ts2mp4(pathname+".ts", pathname+".mp4", option)
33             time.sleep(2)
34 if __name__ == "__main__":
35     usage="usage: "
36     version="%prog 0.9.7"
37     parser=optparse.OptionParser(usage=usage,version=version)
38     parser.add_option("-e","--Encode",action="store",type="string",dest="encode_option",default="",metavar="TITLE",help="encode test(option)")
39     (opts,args)=parser.parse_args(sys.argv)
40     if opts.encode_option != "":##-sの場合
41         test_all_ch_encode(opts.encode_option, 10)