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 import datetime
11
12 import configreader
13 import chdb
14 import tv2mp4
15 import tv2ts
16 def test_all_ch_encode(option,stime):
17     chl=chdb.getall()
18     print chl
19     path= configreader.getpath("test")
20     tpath=os.path.join(path, "encode_test")
21     if not os.path.exists(tpath):
22         os.mkdir(tpath)
23     dnowt=datetime.datetime.now().strftime("%Y-%m-%d_%H:%M:%S")+"("+option+")"
24     tpatht=os.path.join(tpath,dnowt)
25     if not os.path.exists(tpatht):
26         os.mkdir(tpatht)
27     if len(chl)>0:
28         for t in chl:
29             print t
30             pathname=os.path.join(tpatht,t['chtxt'])
31             print pathname
32             tv2ts.tv2ts(pathname+".ts",t['ch'],t['csch'], stime)
33             tv2mp4.ts2mp4(pathname+".ts", pathname+".mp4", option)
34             time.sleep(2)
35 if __name__ == "__main__":
36     usage="usage: "
37     version="%prog 0.9.7"
38     parser=optparse.OptionParser(usage=usage,version=version)
39     parser.add_option("-e","--Encode",action="store",type="string",dest="encode_option",default="",metavar="TITLE",help="encode test(option)")
40     (opts,args)=parser.parse_args(sys.argv)
41     if opts.encode_option != "":##-sの場合
42         print "test_all_ch_encode"
43         test_all_ch_encode(opts.encode_option, "10")